美文网首页
Why would someone use WHERE 1=1

Why would someone use WHERE 1=1

作者: 奋斗的迈腾 | 来源:发表于2017-09-22 16:43 被阅读0次

If the list of conditions is not known at compile time and is instead built at run time, you don't have to worry about whether you have one or more than one condition. You can generate them all like: and <condition>  and concatenate them all together.

it used as an implementation convenience. 

The SQL query engine will end up ignoring the "1=1" so it should have no performance impact.

相关文章

网友评论

      本文标题:Why would someone use WHERE 1=1

      本文链接:https://www.haomeiwen.com/subject/ulmfextx.html