SQL IN Operator

The IN operator is used with the WHERE clause to match values in a list.

The IN operator is a shorthand for multiple OR conditions.

 

Syntax:

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

 

Example Database:

This is  customers  table.

id name Location
1 Kailash Delhi
2 Amit Haryana
3 Siddarth Noida
4 Vikas Noida

 


 

Example: The below query will return records where id is 1 or 3. The query will display the following result.

Syntax:

SELECT * FROM customers WHERE id IN (1,3);

Result:

id name Location
1 Kailash Delhi
3 Siddarth Noida