Possible Duplicates:
Why would a sql query have “where 1 = 1”
Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?
That is a common occurrence in various query instances, and it probably applies to all SQL engines.
People (and especially ORM frameworks) frequently add the always-true condition WHERE 1 = 1 or something similar to a query if there are no conditions declared for it.
So instead of:
SELECT id, name FROM users;
They use:
SELECT id, name FROM users WHERE 1 = 1;
The only reason I can think of for this is if you add conditions dynamically, in which case you don't have to worry about the initial AND being stripped, however, it still happens very frequently that the 1 = 1 condition is stripped if there is an actual condition in the query.
An actual example from CakePHP (generated by the framework):
(no conditions)
SELECT `User`.`id`, `User`.`login`
FROM `users` AS `User` WHERE 1 = 1
ORDER BY `User`.`id` ASC;
(with the condition)
SELECT `User`.`id`, `User`.`login`
FROM `users` AS `User`
WHERE `User`.`login` = 'me@example.com'
LIMIT 1;
Is there any reason for adding that extra condition?