SQL IN Syntax
SELECT column_name(s)
FROM table_name WHERE column_name IN (value1,value2,...) |
IN Operator Example
Id
|
LastName
|
FirstName
|
Address
|
City
|
1
|
Navis
|
Anto
|
Madras
|
TVL
|
2
|
Ji
|
Bala
|
Bombay
|
TVL
|
3
|
Christopher
|
Franklin
|
America
|
KK
|
Now we want to select the persons with a last name equal to "Navis" or "Christopher" from the table above.
We use the following SELECT statement:
SELECT * FROM Persons
WHERE LastName IN ('Navis','Christopher') |
The result-set will look like this:
Id
|
LastName
|
FirstName
|
Address
|
City
|
1
|
Navis
|
Anto
|
Madras
|
TVL
|
3
|
Christopher
|
Franklin
|
America
|
KK
|
0 comments:
Post a Comment