Why the following SQL query show results?
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
but when we change the order of value it will not show any result?
SELECT * FROM Products
WHERE Price BETWEEN 20 AND 10;
SELECT * FROM Products
WHERE Price BETWEEN 20 AND 10;
translates to
SELECT * FROM Products
WHERE Price >= 20 AND Price <= 10;
BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression. NOT BETWEEN returns TRUE if the value of test_expression is less than the value of begin_expression or greater than the value of end_expression.
In your case, your statement evaluates to
greater than or equal to 20 AND less than or equal to 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With