IN
Operator
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,..) |
LastName | FirstName | Address | City |
---|---|---|---|
Hansen | Ola | Timoteivn 10 | Sandnes |
Nordmann | Anna | Neset 18 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
Svendson | Tove | Borgvn 23 | Sandnes |
LastName
equal to “Hansen” or “Pettersen”, use the following SQL:
SQL> select * from Persons 2 where LastName in ('Hansen', 'Pettersen'); |
LastName | FirstName | Address | City |
---|---|---|---|
Hansen | Ola | Timoteivn 10 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
Customers
table may be created by the following command:
SQL> create table Customers ( 2 CustomerID varchar(16), 3 CompanyName varchar(32), 4 ContactName varchar(32), 5 Address varchar(64), 6 City varchar(32), 7 PostalCode varchar(16), 8 Country varchar(32) );Note that the
Customers
table is for read only.