We are using a SQL query to search on the basis of dateFrom and dateTo fields. for that i am using \"greater than equal to(>=)\" and \"less than equ
There is no difference.
(x BETWEEN y AND z)
is the same as writing
((x >= y) AND (x <= z))
Modern databases ship with very intelligent query execution optimisers. One of their main features is query transformation. Logically equivalent expressions can usually be transformed into each other. e.g. as Anthony suggested, the BETWEEN
operator can be rewritten by Oracle (and MySQL) as two AND
-connected comparisons, and vice versa, if BETWEEN
isn't just implemented as syntactic sugar.
So even if there would be a difference (in performance), you can be assured that Oracle will very likely choose the better option.
This means that you can freely choose your preference, e.g. because of readability.
Note: it is not always obvious, what's logically equivalent. Query transformation rules become more complex when it comes to transforming EXISTS
, IN
, NOT EXISTS
, NOT IN
... But in this case, they are. For more details read the specification (chapter 8.3 between predicate):
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
No as such there is no difference(When using ORACLE) but using BETWEEN operator is more elegant way of comparing values for a range.