Jump to content

What's the use of 'WHERE TRUE' ?


terryds

Recommended Posts

Hi, guys... Can you tell me what's the difference between

SELECT column FROM table WHERE TRUE

and

SELECT column FROM table

And

SELECT column FROM table WHERE 1=1

Thanks for any answers

Edited by terryds
Link to comment
Share on other sites

The only reason I'll do something like that is if I have a list of possible where conditions that I may add to the query, and want to make sure there is at least one condition so that everything else can have AND before it. Using those conditions has no other effect on a query, they just tell it to return all rows.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...