I have the following table
Select * from Peeps
Id Name Age
1 Sam 16
2 John NULL
Select
Name,
Age,
(If Age=NULL,1,0) AS Z
from peeps;
Results:
+------+------+---+
| name | age | Z |
+------+------+---+
| Sam | 16 | 0 |
| John | NULL | 0 |
+------+------+---+
Desired Results
+------+------+---+
| name | age | Z |
+------+------+---+
| Sam | 16 | 0 |
| John | NULL | 1 |
+------+------+---+
Try:
http://dev.mysql.com/doc/refman/5.1/en/working-with-null.html