SQL IN

To specify multiple values in WHERE clause, we use IN operator.

IN operator is mainly used when there are multiple OR operators in WHERE clause. 

Syntax:

SELECT * FROM table_name
WHERE column_name IN (value1, value2, ..., valueN);

DEME STUDENTS TABLE

Data
Roll_No Name Marks
1 Dev 35
2 Ayush 45
3 Ram 55
4 Pyush 65
5 Nazim 75

Example: To select students having name Ayush, Ram, and Nazim.

SELECT * FROM students
WHERE Name IN (Ayush, Ram, Nazim);

This will fetch the values as shown below:

Data
Roll_No Name Marks
2 Ayush 45
3 Ram 55
5 Nazim 75

The use of IN operator can be done with subqueries too.

Syntax:

SELECT * FROM table_name
WHERE column_name IN (SELECT STATEMENT);