Sitemap

MySQL IN Operator

Jul 16, 2023

--

The IN operator allows you to specify multiple values in a WHERE clause.

Get Bhavitha Cherukuri’s stories in your inbox

Join Medium for free to get updates from this writer.

The IN operator is a shorthand for multiple OR conditions.

IN Syntax

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

OR

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

Demo Database

The table below shows the complete “Employees” table from the database:

IN Operator Examples

The following SQL statement selects all Employees that are located in “London”, “Seattle” or “Kent”:

Example

SELECT * FROM Employees
WHERE City IN ('London', 'Seattle', 'Kent');

The following SQL statement selects all Employees that are NOT located in “London”, “Seattle” or “Kent”:

Example

SELECT * FROM Employees
WHERE City NOT IN ('London','Seattle', 'Kent');

--

--

Bhavitha Cherukuri
Bhavitha Cherukuri

Written by Bhavitha Cherukuri

My passion for writing motivated me to start writing blogs and the content within is written in a simple and easy format. so that readers can understand easily.