Archive for November 3rd, 2010
10 things in MySQL (that won’t work as expected)
(I just discovered cracked.com)
#10. Searching for a NULL

SELECT * FROM a WHERE a.column = NULL
In SQL, a NULL is never equal to anything, even another NULL. This query won't return anything and in fact will be thrown out by the optimizer when building the plan.
When searching for NULL values, use this instead:
SELECT * FROM a WHERE a.column IS NULL
Subscribe in a reader