In is a special kind of operator which uses with where clauses. In the where expression only one value is allowed to be sent through the query. With help of in operator you can send multiple values in the where clause.
The syntax of IN keyword is as follows:
Syntax
SELECT "column_name"
FROM "table_name"
WHERE "column_name" IN ('value1', 'value2', ...)
Let's you wish to select all records for the Los Angeles and the San Diego stores in Table Store_Information,
The Values inside parenthesis can be one or more, with each values separated by comma. Values can be characters or numerical. If there is only one value inside the parenthesis, then command is equivalent to :-
WHERE "column_name" = 'value1'
Store_name
Sales
Date
Los Angeles
$1500
Jan-05-2005
San Diego
$250
Jan-07-2005
Los Angeles
$300
Jan-08-2005
Boston
$700
Jan-08-2005
Command
SELECT *
FROM Store_Information
WHERE store_name IN ('Los Angeles', 'San Diego')
Output
Store_name
Sales
Date
Los Angeles
$1500
Jan-05-2005
San Diego
$250
Jan-07-2005
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords sql statements, sql server, microsoft sql server, sql queries