ICON

Help Center How To Use Our Products? SQL IN operators

IN operators

1 MIN EXPERT DATA, SQL QUERIES, IN OPERATOR


This functionality is only available in Spotzi Studio.

The IN operator is used to create an SQL query that filters rows based on multiple conditions. The IN operator is mostly used as a short form for multiple OR conditions. A WHERE clause with an IN operator looks like this:

SELECT * FROM {name of dataset}
WHERE {column} IN ({value1}, {value2}, {value3});

In the example below we have a dataset with 2-digit postal codes from the US. Each postal code area has one sales manager, but a sales manager can be responsible for several postal code areas.

IN Query

Let’s say we only want to show the areas where the 2-digit postal code is 11, 12, 16, 20 or 27. In that case the WHERE query will look like this.

SELECT * FROM usa_salesmanagers_2_digit_areas
WHERE pc2_number IN (11, 12, 16, 20, 27);

IN Query

Now let’s say we only want to show the areas where the salesmanager is Rick or Devlin. In that case the WHERE query will look like this.

SELECT * FROM usa_salesmanagers_2_digit_areas
WHERE salesmanager IN ('Rick', 'Devlin');

IN Query

Related blog posts

Try Spotzi for free and start finding your best-fit customers