Possible Duplicate:
Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?
I saw some people use a statement to query a table in a MySQL database like the following:
select * from car_table where 1=1 and value="TOYOTA"
But what does 1=1 mean here?
It’s usually when folks build up SQL statements.
When you add
and value = "Toyota"you don’t have to worry about whether there is a condition before or just WHERE. The optimiser should ignore itNo magic, just practical
Example Code:
Otherwise you would have to have a complicated set of logic: