SQL where 条件始终为真

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8384942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:32:15  来源:igfitidea点击:

SQL where condition always true

sql

提问by Mr. Ghiandino

How to set in SQL a where condition that is always true?

如何在 SQL 中设置始终为真的 where 条件?

As far as I know: where 1=1, are there other ways too?

据我所知:where 1=1还有其他方法吗?

回答by Nonym

Are you, by chance, talking about collapseconditions, where a grouped condition is always TRUEor FALSE?

您是否偶然在谈论collapse条件,其中分组条件始终为TRUEFALSE

WHERE TRUE
WHERE 1
WHERE <string value> = <the same string value>
WHERE <numeric value> = <the same numeric value>
WHERE <hardcoded formula> = <the same hardcoded formula or one that produces the same value>
WHERE NULL IS NULL