Tag Archives: Example of IN operator

IN Operator in SQL Query

Use of IN Operator in SQL Query

IN Operator is worked as equal to operator but it able to match more rows than 1 rows as in Equal operator.
We are able to match multiple data value with column value to get result in single SQL Statement.
If we are not able to use IN operation then as alternative we use UNION ALL and EQUAL to match one by one value.


SELECT * FROM table_name WHERE columnname IN (value1,value2,...);

Example 1:
Find data for multiple values for specific column, it will return result all rows which having country value INDIA and UK.

SELECT * FROM employees WHERE Country IN ('INDIA','UK');

Example 2:
Main use of IN oparator is use of sub-queries. It will used one query output as another query input with IN Operator. In this example you find the department id from department name and find all employees detail of that department number.

select * from employee where deptno in ( select department_no from departments where department_name = 'SALES');