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

后端 未结 5 1666
夕颜
夕颜 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:22

    You need to first make the column nullable:

    @Mysql5.7

    Wrong :

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

    Correct :

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

    Note: Remove the quote from the date value in your where clause. Hope it help someone

提交回复
热议问题