IN
The IN operator may be used if you know the exact value you want to return for at least one of the columns.
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,..) |
Original Table (used in the examples)
LastName | FirstName | Address | City |
Hansen | Ola | Timoteivn 10 | Sandnes |
Nordmann | Anna | Neset 18 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
Svendson | Tove | Borgvn 23 | Sandnes |
Example 1
To display the persons with LastName equal to "Hansen" or "Pettersen", use the following SQL:
SELECT * FROM Persons WHERE LastName IN ('Hansen','Pettersen') |
Result:
LastName | FirstName | Address | City |
Hansen | Ola | Timoteivn 10 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
No comments:
Post a Comment