Date comparison with WHERE clause of UPDATE statement in mysql results in incorrect datetime value

Asked 1 years ago, Updated 1 years ago, 37 views

Comparing dates in the WHERE clause of the UPDATE statement results in an incorrect datetime value.The following is the execution SQL.

UPDATE SHAIN
SET
  COLUMN1 = COLUMN2
WHERE
  DATE_FORMAT(NOW(), '%Y%m%d') <DATE_FORMAT(LAST_DAY(TAISHABI), '%Y%m%d')

If you run under the same conditions in a SELECT statement, no errors are encountered and executed.
I think the error means to put the correct value in the DATETIME type.
Both COLUMN1 and COLUMN2 are VARCHAR types, and the DATETIME type is TAISHABI in the where clause only.
How do I resolve the error?

mysql

2022-09-30 14:47

1 Answers

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.