Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 SQL Question

Author  Topic 

klaine07
Starting Member

5 Posts

Posted - 2012-01-05 : 16:15:51

select count(*) from table1 where col1 = (select col1 from table2 where count=@count) and col2= (select col2 from table2 where count=@count) and col3 = (select col3 from table2 where count=@count)

what i want to do is like this select the col1,col2 and col3 in table 2 with only one select statement.. Is it posible?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-05 : 16:22:44
Does this get you the same result?

select count(*)
from table1
join table2
on table1.col1 = table2.col1 and table1.col2 = table2.col2 and table1.col3 = table2.col3
where table2.count=@count

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -