SQL Select In

HTML
CSS
C#
SQL

SQL Select In

SQL IN is an operator used in a SQL query to help reduce the need to use multiple SQL “OR” conditions. The IN operator allows you to specify multiple values in a WHERE clause. It is used in SELECT, INSERT, UPDATE, or DELETE statements.

Example:

Expression IN (value 1, value 2 … value n); 

We have a table called Employee with four columns:

table called Employee

Take an example with character values.

SELECT * FROM Employee WHERE Emp_Name IN (Ankit, Bheem, Sumit);

 The result will be shown as this table:

 The result will be shown as this table:

SELECT * FROM Employee WHERE Emp_Salary IN (25000, 30000, 40000); 

The result will be shown as this table:

Course Video

NOTE: Practice below questions on site editor.

1. Write SQL Query to get all the records from Person_Person table whose BusinessEntityID is 1, 5 and 10 using IN operator.

Table: (Person_Person)-(3 row count)

2. Write SQL Query to  get  all the records from Production_Culture table where Name is ‘Arabic’,

‘English’,’Thai’ using IN operator
Table: (Production_Culture)-(3 row count)

3. Make a SQL Query to find Name, ShiftID from HumanResource_Shift table where Name is (Day, Night, Evening) using IN operator.

Table: (HumanResource_Shift)-(3 row count)

4. Write SQL Query to get all the columns from HumanResources_EmployeePayHistory table where BusinessEntityID is (1,2,3,4) and Rate is less than 50 Using IN operator.

Table:  (HumanResources_EmployeePayHistory)-(4 row count)

5. Write a SQl Query to get all the records from HumanResources_EmployeePayHistory table where BusinessEntityID is (1,2,3,4,5,6) and Rate is grater than 50 Using IN operator.

Table : (HumanResources_EmployeePayHistory)-(6 row count)