SELECT ... WHERE 1=1
is a pointless waste:
1=1
evaluates to true, so all records will be returned. It's functionally identical to the same select without the where clause (but harder to read, and probably slightly less efficient as the command has to be parsed)
SELECT ... WHERE null=null
is different: nulls propagate in SQL because they aren't "real" values - just a marker for a non-existent value - so any expression with a
null
in it, returns
null
. Since
null
is not true, the WHERE clause always fails, and no rows are returned.
See here:
http://en.wikipedia.org/wiki/Null_(SQL)[
^]