The IN Operator
The IN operator allows you to specify multiple values in a WHERE clause.SQL IN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...)
FROM table_name
WHERE column_name IN (value1,value2,...)
IN Operator Example
The "Persons" table:P_Id | LastName | FirstName | Address | City |
---|---|---|---|---|
1 | Hansen | Ola | Timoteivn 10 | Sandnes |
2 | Svendson | Tove | Borgvn 23 | Sandnes |
3 | Pettersen | Kari | Storgt 20 | Stavanger |
We use the following SELECT statement:
SELECT * FROM Persons
WHERE LastName IN ('Hansen','Pettersen')
WHERE LastName IN ('Hansen','Pettersen')
P_Id | LastName | FirstName | Address | City |
---|---|---|---|---|
1 | Hansen | Ola | Timoteivn 10 | Sandnes |
3 | Pettersen | Kari | Storgt 20 | Stavanger |
No comments:
Post a Comment