What is the difference between NOT (x> y) and (x <y) in an SQL query?
What is the difference between the following query:
SELECT * FROM employee WHERE NOT(start_date > '01-JAN-1970');
and this request:
SELECT * FROM employee WHERE start_date < '01-JAN-1970';
Is there a difference, and if so, how NOT(x > y)is it used differently than (x < y). Can anyone provide an example?
Thanks.
+3
deepu
source
share9 answers
In MySQLandPostgreSQL
SELECT * FROM employee WHERE not(start_date > '01-JAN-1970')
will not use INDEXon start_date, if any, their optimizers are not smart enough.
Otherwise, if you correct a condition that is not necessarily strict in one of the cases (either not(start_date >= '01-JAN-1970'), or start_date <= '01-JAN-1970'), the queries are equal.
+8