Remove all zero dates from MySQL database across all Tables

前端 未结 9 1494
-上瘾入骨i
-上瘾入骨i 2021-01-13 14:37

I have plenty of tables in MySQL which which contains zero date in dateTime column 0000-00-00 00:00:00

Using some sort of admin settings, Is it possibl

9条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 14:55

    This is an old question but was running into a similar problem except I was trying to set the 0000-00-00 to NULL.

    Was trying to query this

    UPDATE tablename SET date_column = NULL WHERE date_column = '0000-00-00';

    and was getting the following error :

    Incorrect date value: '0000-00-00' for column 'date_column' at row 1

    Turns out the following query without '' around the 0000-00-00 worked !

     UPDATE tablename SET date_column = NULL WHERE date_column = 0000-00-00;

提交回复
热议问题