SQL IN Operator
- Previous Page SQL Wildcard
- Next Page SQL Between
IN Operator
The IN operator allows us to specify multiple values in the WHERE clause.
SQL IN Syntax
SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)
Original Table (Used in the Example):
Persons Table:
Id | LastName | FirstName | Address | City |
---|---|---|---|---|
1 | Adams | John | Oxford Street | London |
2 | Bush | George | Fifth Avenue | New York |
3 | Carter | Thomas | Changan Street | Beijing |
IN Operator Example
Now, we want to select people with the surname Adams and Carter from the above table:
We can use the following SELECT statement:
SELECT * FROM Persons WHERE LastName IN ('Adams','Carter')
Result Set:
Id | LastName | FirstName | Address | City |
---|---|---|---|---|
1 | Adams | John | Oxford Street | London |
3 | Carter | Thomas | Changan Street | Beijing |
- Previous Page SQL Wildcard
- Next Page SQL Between