Set value to NULL in MySQL

前端 未结 9 1365
逝去的感伤
逝去的感伤 2020-11-30 01:17

I want a value to be set to NULL if nothing is put into the text box in the form I\'m submitting. How can I make this happen? I\'ve tried inserting \'NULL

9条回答
  •  野性不改
    2020-11-30 02:04

    You're probably quoting 'NULL'. NULL is a reserved word in MySQL, and can be inserted/updated without quotes:

    INSERT INTO user (name, something_optional) VALUES ("Joe", NULL);
    UPDATE user SET something_optional = NULL;
    

提交回复
热议问题