Friday 23 April 2010

Setting an MySQL table value to NULL using WHERE condition

To set an individual entry to NULL:

UPDATE tablename SET columnname = NULL WHERE condition;

So, referring to our Car/Driver table again - http://creating-websites-with-php-and-mysql.blogspot.com/2010/04/updating-mysql-table-row-entry.html

Let's set the Fiesta to have no Driver assigned:

UPDATE DriverTable SET Driver = NULL WHERE Car = 'Fiesta';

No comments:

Post a Comment