SQL – In Operator
Table Of Contents:
- What Is An “In” Operator?
- Syntax Of “In” Operator.
- Examples Of “In” Operator.
(1) What Is An “In” Operator ?
- The
INoperator allows you to specify multiple values in aWHEREclause. - The
INoperator is a shorthand for multipleORconditions.
(2) Syntax Of “In” Operator ?
Syntax:
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...); (3) Examples Of “In” Operator ?
Demo Data:
Example-1: Country in “Germany”, “France” or “UK”
SELECT * FROM Customers
WHERE Country IN ('Germany', 'France', 'UK');
Example-2: Country Not in “Germany”, “France” or “UK”
SELECT * FROM Customers
WHERE Country NOT IN ('Germany', 'France', 'UK');
Example-3: Selects all customers that are from the same countries as the suppliers:
SELECT * FROM Customers
WHERE Country IN (SELECT Country FROM Suppliers);

