---
title: "How do you use the IN operator to compare a column against a list of values in SQL?"  
description: "How do you use the IN operator to compare a column against a list of values in SQL?"  
author: "Revati S Misra"  
published: 2023-07-04  
updated: 2023-07-05  
canonical: https://www.mindstick.com/forum/158942/how-do-you-use-the-in-operator-to-compare-a-column-against-a-list-of-values-in-sql  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# How do you use the IN operator to compare a column against a list of values in SQL?

How do you use the [IN operator](https://www.mindstick.com/articles/12620/use-of-in-operator-in-sql-server) to [compare](https://www.mindstick.com/forum/2036/propertyinfo-getvalue-unable-to-compare-datetimes) a [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) [against](https://yourviews.mindstick.com/view/81332/the-approach-of-science-against-disease-epidemics) a list of [values in SQL](https://www.mindstick.com/forum/159818/how-to-use-the-coalesce-function-to-handle-null-values-in-sql-queries)?

## Replies

### Reply by Aryan Kumar

The `IN` [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) is used to compare a column against a list of specific [values](https://www.mindstick.com/forum/327/sum-textbox-values). It allows you to check if a column's value matches any of the values in the specified list. The syntax for using the `IN` operator is as follows:

```plaintext
SELECT column1, column2, ...
FROM table_name
WHERE column_name IN (value1, value2, ...);
```

In the above syntax, `column1`, `column2`, and so on represent the columns you want to select from the table, and `table_name` represents the name of the table you are querying.

The `column_name` is the column you want to compare against the list of values specified in parentheses. The list of values is enclosed in parentheses and separated by commas.

For example, let's say we have a table called "Employees" with columns "EmployeeID," "FirstName," and "Department." If we want to retrieve the details of employees who belong to either the 'Sales' or 'Marketing' departments, we can use the following query:

```plaintext
SELECT EmployeeID, FirstName, Department
FROM Employees
WHERE Department IN ('Sales', 'Marketing');
```

In this query, the `WHERE` clause specifies the condition `Department IN ('Sales', 'Marketing')`, which checks if the value in the 'Department' column matches either 'Sales' or 'Marketing'. Only the rows that satisfy this condition will be included in the result.

The `IN` operator is particularly useful when you have a large number of values to compare against, as it provides a more concise and readable way of specifying multiple OR conditions.


---

Original Source: https://www.mindstick.com/forum/158942/how-do-you-use-the-in-operator-to-compare-a-column-against-a-list-of-values-in-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
