Can't understand why I get Error Code: 1525. Incorrect DATETIME value: '0000-00-00 00:00:00'
(pls note that it's not a duplicate, since there was no direct answer to the problem)
I have an old db table with data that I want to import using SQL.
In the old table there are columns with '0000-00-00 00:00:00' values. I know about zero-value-dates and >mysql 5.7. and it's ok, whenever I have it, I will to use current_timestamp()
.
In order to do so, I need to check the data first.. So I used this SQL:
INSERT INTO new_table
(
column_a,
date_column
)
SELECT
column_a,
IF(
strcmp(`date_column`,'0000-00-00 00:00:00')=0,
current_timestamp(),
`date_column`
)
FROM
old_table
But it's not working, as mentioned.