HOW TO USE BETWEEN OPERATOR IN SQL?

344 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
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

Ganesh Ji Arti A Tribute to Dilip Kumar