SQL Between

Posted On: February 11, 2016

The BETWEEN operator is used to select values within a collection. The values could be numbers, text, or dates.
Syntax:-

SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;
BETWEEN Example:-
The subsequent SQL statement selects all wears with a price BETWEEN 100 and 200:-

SELECT * FROM Wears WHERE Price BETWEEN 100 AND 200;
NOT BETWEEN Example:-
To display the wears outside the range of 100 and 200, apply NOT BETWEEN:-

SELECT * FROM Wear WHERE Price NOT BETWEEN 100 AND 200;
BETWEEN with IN Example:-
The subsequent SQL statement selects all wears with a price BETWEEN 100 and 200, but wears with a CategoryID of 10,20, or 30 must not be displayed:-

SELECT * FROM wears WHERE (Price BETWEEN 100 AND 200) AND NOT CategoryID IN (10, 20, 30);

Related Post

Also Read :   HTML Comments
X
Subscribe to our newsletter
Subscribe to our newsletter today to receive updates on the latest news and offers.
100% Privacy. No spam guaranteed
webe tutorial
Menu