Syntax of BETWEEN in SQL-
SELECT(ColumnName(s))
FROMย <TableName>
WHERE<ColumnName>
BETWEENย value1ย ANDย value2;
Example of BETWEEN in SQL-
SELECT *
FROMย Products
WHEREย Price
BETWEENย 18ย ANDย 22;
โIt will select all the products with a price between 18 to 22.
Syntax of NOT BETWEEN in SQL-
SELECT(ColumnName(s))
FROMย <TableName>
WHERE<ColumnName>
NOT BETWEENย value1ย ANDย value2;
Example of NOT BETWEEN in SQL-
SELECT *
FROMย Products
WHEREย Price
NOT BETWEENย 18ย ANDย 22;
โIt will select all the products with a price not between 18 to 22.
Note-
Northwind sample database is used for example.
Saraswat World Changed status to publish June 8, 2023
Leave a Reply