IN condition in MYSQL by R4R Team

MYSQL IN condition:
-Basically,The MySQL IN condition is used to reduce the use of multiple OR conditions in a SELECT, INSERT, UPDATE and DELETE statement.

Syntax:
WHERE column IN (value1,value2,...);

Display all record of table employee:

SELECT * FROM employee;

emp_id emp_name department emp_salary
1 Aman D1 34000
2 Ram D2 43000
3 Ramesh D1 20000
4 John D3 65000
5 Sita D1 10000
6 Dinesh D2 15000


Now Display the employee record which belong to the department D1 or D2:

SELECT * FROM employee WHERE department IN ('D1','D2');

emp_id emp_name department emp_salary
1 Aman D1 34000
2 Ram D2 43000
3 Ramesh D1 20000
5 Sita D1 10000
6 Dinesh D2 15000



Leave a Comment: