motioneye
asked on
Tsql , why use where 1-1 in Tsql query ?
I've seen seen in one of our developed t-sql query code were written with where 1=1 and *****.
I just don't get it why it must with where 1=1 and then only followed by the actual condition, mind someone here to explain.
I just don't get it why it must with where 1=1 and then only followed by the actual condition, mind someone here to explain.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(another possibility based on my current gig that I started after the last comment)
Maybe the client has a big honkin' UI that parses dynamic SQL based on user selections, and if the user doesn't select anything relevant then the UI passes a WHERE 1 = 1. Uglo-riffic!
Thanks for the split, good luck with your project. -Jim
Maybe the client has a big honkin' UI that parses dynamic SQL based on user selections, and if the user doesn't select anything relevant then the UI passes a WHERE 1 = 1. Uglo-riffic!
Thanks for the split, good luck with your project. -Jim
& It is also just a convention.
It could be 'a' = 'a' that gets used, but 1=1 is way easier to type :)
no points pl.