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

前端 未结 11 838
孤独总比滥情好
孤独总比滥情好 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 17:59

    Semantically, the two expressions have the same result.

    However, BETWEEN is a single predicate, instead of two comparison predicates combined with AND. Depending on the optimizer provided by your RDBMS, a single predicate may be easier to optimize than two predicates.

    Although I expect most modern RDBMS implementations should optimize the two expressions identically.

提交回复
热议问题