ICON

Help - SQL IN operators

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

Interested in our solutions? Please contact our sales team.

Whether you are new to data analytics or already an expert. We offer solutions for everyone. You don’t need to be a data expert to work with Spotzi Location. For more tailor made solutions we offer Spotzi Studio. With this plan you cannot only manage the data yourself but also connect to our API and manage users for the dashboards you create. Or work with our Market Ready Dashboards and drive on autopilot.