In this tutorial you will learn about the MySQL IN Clause and its application with practical example.
The IN clause is used to match multiple values in a WHERE clause.
Table Of Contents−
Syntax:
1 2 3 |
SELECT <field1, field2,...> FROM <table_name> WHERE <field> IN (value1,value2,...) |
Consider “emp_info” table:
empID | empName | sale |
---|---|---|
1 | Mark | 1000 |
2 | Max | 1000 |
3 | Mark | 1000 |
4 | Mark | 1000 |
5 | John | 1000 |
1 2 |
SELECT * FROM emp_info WHERE EMPNAME IN ('Mark','Max') |
Output:
empID | empName | sale |
---|---|---|
1 | Mark | 1000 |
2 | Max | 1000 |
3 | Mark | 1000 |
4 | Mark | 1000 |