T-SQL 101: 25 Checking lists of values in SQL Server T-SQL by using the IN operator
The T-SQL IN operator allows you to choose from a list of matching values.
In the top case shown below:
I’ve said where StateName is one of QLD, NSW, or VIC.
Now see that’s exactly the same as if I had written the option shown at the bottom where I said:
where StateName equals QLD or StateName equals NSW or StateName equals VIC.
The two options work exactly the same and mean the same thing, so having an IN operator is logically equivalent to having a whole lot of predicates joined by OR operators.
2019-07-08