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?
If you enable NO_ZERO_DATE
of sql_mode
to make a question or state of update
with a record such as '0000-00-00'
exists.
("Incorrect datetime value" message and the error value are not printed as well.)
In this case, if you do not enable NO_ZERO_DATE
in sql_mode
settings, you will pass update
.
© 2024 OneMinuteCode. All rights reserved.