SQL Server 2008 IN ALL Query

Go To StackoverFlow.com


Is there a easy way to do an IN ALL command in SQL?

For example if I had:

SELECT * FROM [table] WHERE col IN (1,2) 

this is really the same as:

SELECT * FROM [table] WHERE col = 1 OR col = 2

but what I really want is:

SELECT * FROM [table] WHERE col = 1 AND col = 2
2012-04-04 18:20
by Adam


FROM [table]
WHERE col IN (1,2) 
group by id
having count(distinct col) = 2
2012-04-04 18:22
by RedFilter
His second query would never return any records would it - Abe Miessler 2012-04-04 18:25
@Abe An example of what I think is being asked is, "show me all the companies that have addresses in both Dallas and Austin" - RedFilter 2012-04-04 18:27