The IN Operator
IN matches values from a list - cleaner than multiple ORs.
Syntax
sql
1SELECT * FROM students
2WHERE column IN (value1, value2, value3);Example
Find Python, JavaScript, or Ruby students:
sql
1SELECT * FROM students
2WHERE course IN ('Python', 'JavaScript', 'Ruby');Equivalent To
sql
1-- IN is cleaner than:
2SELECT * FROM students
3WHERE course = 'Python'
4OR course = 'JavaScript'
5OR course = 'Ruby';With Numbers
sql
1-- Students aged 12, 14, or 15
2SELECT * FROM students
3WHERE age IN (12, 14, 15);