How to store NULL values in datetime fields in MySQL?

后端 未结 8 526
再見小時候
再見小時候 2020-11-29 05:44

I have a \"bill_date\" field that I want to be blank (NULL) until it\'s been billed, at which point the date will be entered.

I see that MySQL does not like NULL val

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 06:21

    I just discovered that MySQL will take null provided the default for the field is null and I write specific if statements and leave off the quotes. This works for update as well.

    if(empty($odate) AND empty($ddate))
    {
      $query2="UPDATE items SET odate=null, ddate=null, istatus='$istatus' WHERE id='$id' ";
    };
    

提交回复
热议问题