9

Why?

SELECT ...
FROM ...
WHERE ... AND 1=1;

Comments
  • 0
    It being an AND statement is weird but I do 1=1 if I need to do condition statements in the WHERE clause.
  • 1
    It also makes building SQL on the fly easier from scripts.
  • 0
  • 3
    @LMestre14 You don't have to worry about where your last WHERE is, you can just keep building them as AND when looping through conditions, then hard code the ; at the end.

    And [code blah] and [blah] and [blah] and 1=1;
  • 0
    I also use to easily enable/disable test "where" statements:

    where (
    1=1
    or
    (
    Col1=value
    and
    Col2=value
    )
    or
    ...

    Just to keep the tests without removing them
  • 0
    This is genius oO
Add Comment