The BETWEEN operator

  • Which of the following SQL Statements is more efficient?

    A) SELECT * FROM PRODUCTS WHERE PRODUCT_DATE BETWEEN '1/1/2001' AND '1/10/2002'

    B) SELECT * FROM PRODUCTS WHERE PRODUCT_DATE >= '1/1/2001' AND PRODUCT_DATE < '1/10/2002'

    Is it A or B or both?

    (and yes, I am aware that they both may produce slightly different results)

    Thanks in advance

    Billy

  • If you look at the execution plan they are the pretty much the same except BETWEEN treates '1/10/2002'

    as <= where you have <. Also, it may be a fraction a of secound difference to for BETWEEN to execute as opposed to the other as BETWEEN hints the relation of the two items where the other the QUERY managaer must make the determination.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply