What does “WHERE 1” mean in SQL?

后端 未结 3 1207
情话喂你
情话喂你 2021-01-03 21:37

Sometimes phpMyAdmin generates queries like:

SELECT * 
FROM  `items` 
WHERE 1 
LIMIT 0 , 30

I wonder if WHERE 1 has any meanin

3条回答
  •  梦毁少年i
    2021-01-03 22:19

    I'd guess it's a string-concatenation artefact: if no where conditions are specified, a "1" is output. That way it does not have to be decided whether the WHERE keyword should be output or not.

    Also you can always output it and simply concatenate conditions with "AND" and "OR". You don't have to decide that the first condition should not start with AND, OR keyword.

提交回复
热议问题