The IN operator is used to determine if a specified value matches any values returned by the query. The IN operator may be used with all main statements such as SELECT, INSERT, UPDATE or DELETE. The following example shows a basic usage of the IN operator:

Syntax

SELECT columns FROM table_name WHERE (expression | column) IN ('value1','value2',...);

We can use an expression or a column name to specify condition, and just list the values we want it to match it against.

Here is a more realistic example of the IN operator:

SELECT city, phone FROM branches WHERE countries IN ('USA', 'France', 'Italy');

The above example will list all cities and phones from those branches located in USA, France, and Italy.

We can also use the IN operator in a nice subquery, which comes very handy in data querying:

SELECT order, customer, status FROM orders WHERE order IN (

   SELECT order FROM order_details GROUP BY order 

   HAVING SUM (quantity * price_each) > 10);