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

后端 未结 19 2230
甜味超标
甜味超标 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:46

    Here's a closely related example: using a SQL MERGE statement to update the target tabled using all values from the source table where there is no common attribute on which to join on e.g.

    MERGE INTO Circles
       USING 
          (
            SELECT pi
             FROM Constants
          ) AS SourceTable
       ON 1 = 1
    WHEN MATCHED THEN 
      UPDATE
         SET circumference = 2 * SourceTable.pi * radius;
    

提交回复
热议问题