SQL in Operator
SQL Tutorial » SQL in Operator
SQL "IN" (without quotes) operator allows you to specify multiple values in a " WHERE" clause.
SQL "IN" (without quotes) is a shorthand for multiple OR conditions.
Syntax1:
FROM table_name
WHERE column_name IN (value1, value2, ...valueN);
Syntax2:
FROM table_name
WHERE column_name IN (SELECT STATEMENT);
Let's look at the "Users" table: We will have six columns as: "id", "first_name", "last_name", "country" and "city":
ID | First Name | Last Name | Country | City |
---|---|---|---|---|
1 | Clark | Kent | USA | Boston |
2 | Pire | Joveau | France | Paris |
3 | Nicky | Anderson | USA | New York |
4 | Pepe | Martínez | Spain | Madrid |
5 | Peter | Parker | SUA | New York |
SQL IN Operator Examples
In the next examples we display people located in "USA" and "Spain"::
Output displayed:
ID | First Name | Last Name | Country | City |
---|---|---|---|---|
1 | Clark | Kent | USA | Boston |
3 | Nicky | Anderson | USA | New York |
4 | Pepe | Martínez | Spain | Madrid |
5 | Peter | Parker | SUA | New York |
Related subjects:
How to create database phpmyadmin?
Select data form database
Insert into SQL
SQL update
PSql delete row
Tags: SQL in operator, access, list, array, python, java, c++, visual studio, excel
What is the IN operator in SQL?
How do you use the IN operator in an SQL query?
Is in a logical operator in SQL?
What is == in SQL?
SQL IN operator
The next example SQL statement selects all customers that are NOT located in "USA" and "France":
WHERE Country NOT IN ('USA', 'France');
Output displayed:
ID | First Name | Last Name | Country | City |
---|---|---|---|---|
4 | Pepe | Martínez | Spain | Madrid |
SQL in Operator
If we have a supplier for a specific product in Spain as an example and we want to select all users who come from the same country as the supplier, SQL statement will look like this:
WHERE Country IN (SELECT Country FROM Suppliers);
Output displayed:
ID | First Name | Last Name | Country | City |
---|---|---|---|---|
4 | Pepe | Martínez | Spain | Madrid |
sql in operator, access, list, array, python, java, c++, visual studio, excel
What is the IN operator in SQL?
How do you use the IN operator in an SQL query?
Is in a logical operator in SQL?
What is == in SQL?
SQL in Operator - sql tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.