Proper way to handle 'optional' where clause filters in SQL?

前端 未结 5 1164
广开言路
广开言路 2020-12-31 23:12

Let\'s say you have a stored procedure, and it takes an optional parameter. You want to use this optional parameter in the SQL query. Typically this is how I\'ve seen it don

5条回答
  •  鱼传尺愫
    2020-12-31 23:38

    You're using "OR" clause (implicitly and explicitly) on the first two SQL statements. Last one is an "AND" criteria. "OR" is always more expensive than "AND" criteria. No you're not crazy, should be expected.

提交回复
热议问题