muttley91 muttley91 - 2 years ago 89
SQL Question

Set value to NULL in MySQL

I want a value to be set to

if nothing is put into the text box in the form I'm submitting. How can I make this happen?
I've tried inserting
but this just adds the word
into the field.

I'm not sure what code I should provide for this, I'm just writing an UPDATE query.

Answer Source

Don't put NULL inside quotes in your update statement. This should work:

UPDATE table SET field = NULL WHERE something = something
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download