HOW TO USE BETWEEN OPERATOR IN SQL?

333 viewsSQLSQL
1

HOW TO USE BETWEEN OPERATOR IN SQL?

Saraswat World Changed status to publish June 8, 2023
1
BETWEEN in SQL
BETWEEN in SQL

BETWEENย operator fetches the records from the table within the range specified in the query. Between Operator includes the starting and ending values of the specified range.

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.

NOT BETWEENย operator fetches the records from the table outside the range specified in the query.

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
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

A Tribute to Dilip Kumar