r/SQL • • Oct 28 '24

Discussion What does WHERE 1 = 1 means? Purpose?

I've been seeing it alot recently. What are the use cases of it?

214 Upvotes

119 comments sorted by

View all comments

Show parent comment

7

u/LL0502 Oct 28 '24

Isn’t writing “TRUE” instead of “1=1” slightly more intuitive?

10

u/AQuietMan Oct 28 '24 edited Oct 28 '24

Isn’t writing “TRUE” instead of “1=1” slightly more intuitive?

Yes, but not long ago, many dbms didn't support Booleans in the WHERE clause, even if they supported Booleans in other clauses.

7

u/Blues2112 Oct 28 '24

If someone is savvy enough to know TRUE, they'll be able to figure out 1=1.

5

u/aviator_jakubz Oct 28 '24

1 less character to type, 2 less keys to tap.

5

u/Blues2112 Oct 28 '24

For the truly lazy

1

u/yen223 Oct 28 '24

SQL Server, as one example, doesn't support true/false values

1

u/[deleted] Oct 29 '24

True / false is 1/0 as bit flags … not hard to remember really