Differences
This shows you the differences between two versions of the page.
docs:mysql:null_values [2007/03/23 15:27] – created billh | docs:mysql:null_values [2008/08/03 00:25] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== NULL Values ====== | ||
+ | ===== searching for ===== | ||
+ | If you want to search for column values that are NULL, you cannot use an expr = NULL test. The following statement returns no rows, because expr = NULL is never true for any expression: | ||
+ | <code mysql> | ||
+ | mysql> SELECT * FROM my_table WHERE phone = NULL; | ||
+ | </ | ||
+ | |||
+ | To look for NULL values, you must use the IS NULL test. The following statements show how to find the NULL phone number and the empty phone number: | ||
+ | <code mysql> | ||
+ | mysql> SELECT * FROM my_table WHERE phone IS NULL; | ||
+ | mysql> SELECT * FROM my_table WHERE phone = ''; | ||
+ | </ | ||