In Oracle, is starting the SQL Query's WHERE clause with 1=1 useful?

前端 未结 3 972
温柔的废话
温柔的废话 2021-01-02 23:50

I\'m working with a client that starts almost all of their WHERE clauses in Oracle with 1=1. Forgive my ignorance, but isn\'t this a no-op? Are there any negati

3条回答
  •  [愿得一人]
    2021-01-03 00:45

    It's done to simplify dynamic SQL generation. Basically each condition can be added as AND without treating the first condition as special (it's preceded by WHERE not AND) or even worrying if there should be a WHERE clause at all.

    So just write it off as easy of use or, arguably, laziness.

提交回复
热议问题