The IN operator allows you to give multiple values in a WHERE clause. SQL IN operator is used in SQL statements to help reduce the multiple SQL "OR" conditions. It is used in SELECT, INSERT, UPDATE or DELETE statement.

IN Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...);

OR

SELECT column_name(s)
FROM table_name
WHERE column_name IN (SELECT STATEMENT);

Example:

The Following SQL Statement selects all Records from Student Table.

select * from Student

Result:

How to use IN operator  in SQL Server

IN Operator Examples

The following SQL statement selects all students that are age in "20", "21"26 and "22" Year.

SELECT * FROM student WHERE age IN (20,21,26,22)

Result:

How to use IN operator  in SQL Server

Thanks.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like