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

前端 未结 5 831
-上瘾入骨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

    The IN version is much clearer and, since it's a single term, avoids the possibility of missing or incorrectly structured parentheses if you add other terms to the WHERE clause.

    In addition, I believe that more SQL implementations will optimize the IN version assuming that an index is available.

提交回复
热议问题