Have you ever seen code like this:

1
2
3
4
5
6
7
8
SELECT
A
, B
, C
FROM TabA
WHERE 1=1
AND A = 'Foo'
AND B = 'Bar'

The simple answer is that, this is just for some lazy debugging.

Let’s say you have the similar code:

1
2
3
4
5
6
7
SELECT
A
, B
, C
FROM TabA
WHERE A = 'Foo'
AND B = 'Bar'

and you briefly want to ignore the first filter “A = ‘Foo’” for testing purposes. You would end up with

1
2
3
4
5
6
7
SELECT
A
, B
, C
FROM TabA
--WHERE A = 'Foo'
WHERE B = 'Bar'

Notice that the ‘WHERE’ line was commented out and therefore the next ‘AND’ needs to turn in a ‘WHERE’ to allow the syntax to remain correct.

As a result a number of developers will always make the WHERE clause ‘WHERE 1=1’ to avoid ever needing to comment it out and therefore never needing to change the next ‘AND’ to ‘WHERE’.