Sometimes phpMyAdmin generates queries like:
SELECT *
FROM `items`
WHERE 1
LIMIT 0 , 30
I wonder if WHERE 1 has any meaning in a query like that.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It doesn’t. It means
ALWAYS TRUEso it won’t have any filtering impact on your query. Query planner will probably ignore that clause.It’s usually used when you build a client side query by concatenating filtering conditions.
So, if your base query is stored in a string like this (example is in PHP, but it certainly applies to many other languages):
Then you can just concatenate a lot of filtering conditions with an
ANDclause regardless of it being the first condition you are using or not: