In MySQL, the IN operator is used to allow us specify multiple values in a WHERE clause.
IN Operator Syntax
SELECT column_name
FROM table_name
WHERE column_name IN (value1,value2,...);
We have a table "employee" as below:
employee
id first_name last_name country
.......................................................
1 John Simp Canada
2 Chris Hely Canada
3 Max Roy Korea
4 Jenny Mill Canada
5 Jack Simpson London
IN Operator Example
The below statement selects all employee with a country "Canada" or "Korea":
SELECT * FROM employee
WHERE country IN ('Canada','Korea');
Result
id first_name last_name country
.......................................................
1 John Simp Canada
2 Chris Hely Canada
3 Max Roy Korea
4 Jenny Mill Canada
Hope this will help you :)
0 Comment(s)