SQL where field in vs. where field = with multiple ors?

前端 未结 5 834
-上瘾入骨i
-上瘾入骨i 2021-02-07 09:01

Which of these is better to use in regard to performance? ...in regard to readability / understandability? ...in regard to accepted standards?

SELECT *
FROM Wher         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-07 09:55

    I would say the first option involving in:

    SELECT *
    FROM Wherever
    WHERE Greeting IN ('hello', 'hi', 'hey')
    

    It is:

    • much faster
    • easier to read
    • no need to use multiple or
    • less typing
    • easier to maintain in big queries
    • widely used

    More Stuff:

    SQL IN Directive Much Faster Than Multiple OR Clauses

提交回复
热议问题