⚡ 180+ new openings posted today

SQL IN Operators

The IN operators is used in WHERE condition with SELECT, UPDATE, and DELETE statement.

The IN operator returns values that matches values in a list or subquery.

The IN operators is a shorthand for multiple OR conditions.

Syntax

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

Example — Original Example

Imagine a college has a table called Students:

RollNoNameCourse
101AaravBCA
102MeeraBBA
103KabirBCA
104RiyaBTech
105ArjunMCA

Suppose we want to find students studying BCA, MCA, or BTech.

SELECT *
FROM Students
WHERE Course IN ('BCA', 'MCA', 'BTech');

Result

RollNoNameCourse
101AaravBCA
103KabirBCA
104RiyaBTech
105ArjunMCA

The query checks whether the Course value is one of the three values specified inside IN.

Leave a Comment

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

Scroll to Top