To select from a list of values in SQL Server, you can use the IN operator in your SELECT statement. The IN operator allows you to specify multiple values to match in a column.
Example Query:
sqlCopy code
SELECT *
FROM your_table
WHERE column_name IN (‘value1’, ‘value2’, ‘value3’);
Explanation:
Replace your_table with the name of your table.
Replace column_name with the column from which you want to select values.
List the values you want to match inside the IN parentheses, separated by commas.
Example Usage:
Suppose you have a Customers table and you want to select customers who live in either ‘New York’, ‘Los Angeles’, or ‘Chicago’:
sqlCopy code
SELECT *
FROM Customers
WHERE City IN (‘New York’, ‘Los Angeles’, ‘Chicago’);
This query will return all rows from the Customers table where the City is one of the specified values.