Set value to NULL in MySQL
You should insert null
, not the string of 'NULL'
.
Don't put NULL
inside quotes in your update statement. This should work:
UPDATE table SET field = NULL WHERE something = something
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;
UPDATE MyTable
SET MyField = NULL
WHERE MyField = ''