How do I make a query return nothing when there are no conditions?

前端 未结 1 1763
傲寒
傲寒 2021-01-29 13:33

Rather simple, I have a one to many / many to one relation and I\'d like to query it. However, I don\'t want any results returned when it isn\'t provided with any WHERE clause

1条回答
  •  长发绾君心
    2021-01-29 14:17

    You could add a where clause that is always false and append the condition you want supplied with OR:

    select * from table where 1 = 0 OR (real conditions)
    

    0 讨论(0)
提交回复
热议问题