SQL IN
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 |
 |
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
|
|