Using IN and BETWEEN Operators in SQL

IN Operator:

IN clause is used with the WHERE clause to specify discrete values. The syntax is as follows:
Syntax:

SELECT column1, column2….
FROM table_name
WHERE column1 IN (value1, value2….);

Example:
Let us consider the Student_details table.

Name Roll No. Marks
Akshay 1 57
Charu 2 68
Disha 3 52
Eva 4 68
Himanshu 5 75
Jitesh 6 88

 

SELECT * FROM Students_details
WHERE Roll_no IN (2, 5);

NameRoll No.Marks

Charu 2 68
Himanshu 5 75

Become a Database Architect

BETWEEN Operator:

It is used to select a value within the specified range. The values can be number, text, or dates.IN operator provides the discrete values and BETWEEN operator provides the range in the search.Syntax:SELECT column1, column2….FROM table_nameWHERE column1 BETWEEN Value1 AND Value2;Example:SELECT * FROM Student_detailsWHERE Roll_no BETWEEN 2 AND 5;

Name Roll No. Marks
Charu 2 68
Disha 3 52
Eva 4 68
Himanshu 5 75

 

Course Schedule

Name Date Details
SQL Training 25 Mar 2023(Sat-Sun) Weekend Batch
View Details
SQL Training 01 Apr 2023(Sat-Sun) Weekend Batch
View Details
SQL Training 08 Apr 2023(Sat-Sun) Weekend Batch
View Details

Leave a Reply

Your email address will not be published. Required fields are marked *