How to create fast database queries

Archive for November 3rd, 2010

10 things in MySQL (that won’t work as expected)

with 45 comments

(I just discovered cracked.com)

#10. Searching for a NULL

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:

FROM    a
WHERE   a.column IS NULL

Read the rest of this entry »

Written by Quassnoi

November 3rd, 2010 at 11:00 pm

Posted in MySQL