vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I had this code in a script: UPDATE food_foods SET included=true WHERE verification_status = 'I'; UPDATE food_foods SET included=false WHERE verification_status IS NULL; I tried replacing it with: UPDATE food_foods SET included=(verification_status = 'I'); However, that set included to true only where verification_status=I, it didn't set false at all. Why doesn't this work? Chris ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| On Mon, Jan 30, 2006 at 04:44:21PM +0800, Christopher Kings-Lynne wrote: > I had this code in a script: > > UPDATE food_foods SET included=true WHERE verification_status = 'I'; > UPDATE food_foods SET included=false WHERE verification_status IS NULL; > > I tried replacing it with: > > UPDATE food_foods SET included=(verification_status = 'I'); (NULL = 'I') is null, not false. It will simply set rows where verification_status is NULL to NULL also. Perhaps you mean IS NOT DISTNCT FROM or something similar? Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFD3dyqIB7bNG8LQkwRAgXlAJ4ml3JIIpZzEuHuEMEXjT UIHyAm2gCdGW6A N0T4oVMKMO+puER6Xvj2LCg= =e80Q -----END PGP SIGNATURE----- |
| ||||
| Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes: > I tried replacing it with: > UPDATE food_foods SET included=(verification_status = 'I'); > However, that set included to true only where verification_status=I, it > didn't set false at all. You'd have gotten NULL, not FALSE, at the rows where verification_status is NULL. You could try coalesce, or "(verification_status = 'I') IS TRUE", to get something that returns false instead of null. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| Thread Tools | |
| Display Modes | |
|
|