Using IN and BETWEEN Operatores 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.

NameRoll No.Marks
Akshay157
Charu268
Disha352
Eva468
Himanshu575
Jitesh688

 

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

NameRoll No.Marks

Charu268
Himanshu575

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;

NameRoll No.Marks
Charu268
Disha352
Eva468
Himanshu575

 

Leave a Reply

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