IN clause in MySQL

MySQL IN In MySQL, the IN condition filters the results obtained through the SELECT, INSERT, UPDATE, and DELETE statements to replace the use of multiple OR conditions.

Syntax:

WHERE expressions IN (value1, value2, .... value_n);

Parameters:

expressions: It is used to specify a column or a field. value_1, value_2… value_n: They are used to specify the values to be tested against the expressions.

Example: Items table:

ID NAME QUANTITY
1 Electronics 30
2 Sports 45
3 Fashion 100
4 Grocery 90
5 Toys 50

 

Query:

SELECT *
FROM items
WHERE quantity IN (30, 45, 50)
ORDER BY name;

Output:

ID NAME QUANTITY
1 Electronics 30
2 Sports 45
5 Toys 50
Please follow and like us:
Content Protection by DMCA.com