Reputation: 4443
I'm using SQL Server 2012.
My SQL query stands as below:
USE Mydatabase
SELECT TravelagencyId, Name
FROM dbo.TravelAgency
I need to add this WHERE line to the query:
WHERE TravelagencyId = (650,651,652,800,952,976)
I am aware that if the list of numbers are consecutive or fall between a range, I can write something like:
WHERE TravelagencyId BETWEEN 650 AND 976
but here there are Ids that I want to exclude from the filter.
Any help on how to write this WHERE
filter?
Upvotes: 0
Views: 9092
Reputation: 37023
You should be using not in where you want to exclude the values that you have.
USE Mydatabase
SELECT TravelagencyId, Name
FROM dbo.TravelAgency
where TravelagencyId in (650,651,652,800,952,976)
Upvotes: 2