Re: NULL VALUE

From: Date: Mon, 03 Jan 2005 18:16:03 +0000
Subject: Re: NULL VALUE
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-37954@lists.php.net to get a copy of this message
first off it would help if you specified what DB you are using and if you are using a DB abstraction lib like PEAR::DB or something similar. also have you tried running these lines directly in a cmdline sql client? is the status column variable width? if not then the value may be 'Active ' (number of padded spaces dependent on length of the field) instead of 'Active'. LightBulbMoment (tm): 5 seconds of searching on the MYSQL site tells me STATUS is a keyword. try either renaming your field or using backticks to escape the name e.g.: $query = 'UPDATE EMPLOYEE SET STATUS=\'Inactive\' where STATUS IS NULL'; I'm willing to bet you haven't bother to: a. RT(F)M. b. check the errors returned. Perry, Matthew (Fire Marshal's Office) wrote:
My "status" column in my Employee table should have two values "Active" and "Inactive". Right now all the active employees have the value "Active" and the rest have a NULL value. Why is it that the following commands do nothing? UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS != 'Active'; UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS <> 'Active';
these should work - expect for the STATUS keyword issue.
UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS IS NULL';
this one has a typo (extra ' at the end)
UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS = ''; UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS = NULL;
these 2 shouldn't work at all.
- Matthew


« previous php.db (#37954) next »