Why would someone use WHERE 1=1 AND in a SQL clause?

后端 未结 19 2025
甜味超标
甜味超标 2020-11-22 07:08

Why would someone use WHERE 1=1 AND in a SQL clause (Either SQL obtained through concatenated strings, either view definition)

I\'ve

19条回答
  •  长发绾君心
    2020-11-22 07:38

    I first came across this back with ADO and classic asp, the answer i got was: performance. if you do a straight

    Select * from tablename

    and pass that in as an sql command/text you will get a noticeable performance increase with the

    Where 1=1

    added, it was a visible difference. something to do with table headers being returned as soon as the first condition is met, or some other craziness, anyway, it did speed things up.

提交回复
热议问题