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
 General SQL Server Forums
 New to SQL Server Programming
 compare column of two tables

Author  Topic 

eugz
Posting Yak Master

210 Posts

Posted - 2011-02-24 : 13:12:16
Hi All.

I would like to compare data of two table and get result where value of column is the same. What I did wrong?

SELECT * FROM Table1 a
WHERE EXISTS
(SELECT * FROM Table2 b
WHERE b.BBB_Name = a.AAA_Name)

Thanks.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-24 : 13:46:40
select A.AAA_Name
from table1 a
inner join table2 b on A.AAA_name=b.BBB_name

Will give you the names that exists in both

Cheers
MIK
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-24 : 13:46:40
select A.AAA_Name
from table1 a
inner join table2 b on A.AAA_name=b.BBB_name

Will give you the names that exists in both

Cheers
MIK
Go to Top of Page
   

- Advertisement -