![]() Preserved Topic: NULL MySQL values. (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
![]() I seem to recall in a past message someone making an offhanded comment about how using NULL values in a MySQL table is questionable practice. I think I understand why now. It would seem you can not use null in a where clause, err, you can, but it doesn't match with null values. |
Paranoid (IV) Inmate From: New Jersey, USA |
![]() You can use null in a where clause, but not with regular operators (i.e., =, !=) you must use IS NULL or IS NOT NULL when trying to match null values in tables. |
Paranoid (IV) Inmate From: other places |
![]() |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
![]() Hm, thanks, sadly that adds a lot of complexity to my PHP scripts since any one of 20 fields could be null. Luckily the empty string solution seems to work great as long as I reserve the integer 0 only for 'empty' fields. |
Paranoid (IV) Inmate From: New Jersey, USA |
![]() Because NULL does not have a definable value. The only way to describe null, is that it has no value, which is why you can't use mathematical operators to test for null, you can't compare something that has no legal value. |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
![]() I have used test for "Is NULL" and "Is Not NULL" on MySQL, Sybase, and Access. I don't know if it's ANSII standard, but a lot of databases seem to use it. |