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
 Transact-SQL (2008)
 How to use other tables values as condition in sel

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-06-06 : 11:13:11
I want to get all data for table1 based on accts available in table2.accts

select * from table1 where accts in (select accts from table2)

what is teh best way to extract / get the complete data using select.

Thanks a lot for the helpful info.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-06-06 : 11:24:56
SELECT A.* FROM Table1 A
INNER JOIN Table2 B on A.Accts=B.Accts

Cheers
MIK
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-06-06 : 12:08:34
The best way.. well that depends..

What is the cardinality between the two tables? What is the table structure? Indexes? How may rows are in each table?
Go to Top of Page
   

- Advertisement -