How to set to NULL a datetime with 0000-00-00 00:00:00 value?

后端 未结 5 1681
夕颜
夕颜 2021-02-08 18:37

I need to change a few values on my DB.

I forgot to set nullable to the table and it set to 0000-00-00 00:00:00 by default.

Now I need to convert that value in <

5条回答
  •  你的背包
    2021-02-08 19:16

    Unfortunately this will not work.
    for:

    update episodes set `ending` = NULL 
    WHERE `ending` = '0000-00-00'
    

    If 0000-00-00 is in the where clause, you get the error:

    "1292 - Incorrect datetime value: '0000-00-00' for column 'ending' at row 1".

    even if ending has NULL and defalut=null in field definition.

提交回复
热议问题