Why use the BETWEEN operator when we can do without it?

前端 未结 11 841
孤独总比滥情好
孤独总比滥情好 2020-12-09 17:31

As seen below the two queries, we find that they both work well. Then I am confused why should we ever use BETWEEN because I have found that BETWEEN behaves differently in d

11条回答
  •  时光取名叫无心
    2020-12-09 18:17

    BETWEEN in T-SQL supports NOT operator, so you can use constructions like

    WHERE salary not between 5000 AND 15000; 
    

    In my opinion it's more clear for a human then

    WHERE salary < 5000 OR salary > 15000;
    

    And finally if you type column name just one time it gives you less chances to make a mistake

提交回复
热议问题