BETWEEN operator vs. >= AND <=: Is there a performance difference?

后端 未结 5 755
旧巷少年郎
旧巷少年郎 2020-12-19 00:17

These two statements are logically equivalent:

SELECT * FROM table WHERE someColumn BETWEEN 1 AND 100

SELECT * FROM table WHERE someColumn >= 1 AND someC         


        
5条回答
  •  一整个雨季
    2020-12-19 01:01

    No, no performance benifit. Its just a little candy.

    If you were to check a query comparison, something like

    DECLARE @Table TABLE(
            ID INT
    )
    
    SELECT  *
    FROM    @Table
    WHERE   ID >= 1 AND ID <= 100
    
    SELECT  *
    FROM    @Table 
    WHERE   ID BETWEEN 1 AND 100
    

    and check the execution plan, you should notice that it is exactly the same.

提交回复
热议问题