Re: NULL VALUE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

















-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux