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

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

    Indirectly Relevant: when 1=2 is used:

    CREATE TABLE New_table_name 
    as 
    select * 
    FROM Old_table_name 
    WHERE 1 = 2;
    

    this will create a new table with same schema as old table. (Very handy if you want to load some data for compares)

提交回复
热议问题