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 2000 Forums
 Transact-SQL (2000)
 sql row comparison

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-02-26 : 07:52:26
Roksana writes "I have 2 tables. Tab1 has list of stores & the product it carries. Tab2 is the master product list. When I compare the two tables I want only Store# 1 to be returned in the result set as it matches the complete & exact set of tab2. Example:
Tab1 Tab2
Str#Prod Prod
1 A A
1 B B
1 C C
2 A
2 B
2 D
Thanks."

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-02-26 : 09:01:43
See INNER JOIN in Books Online. If this is a student, we don't answer homework questions here.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

claire
Starting Member

19 Posts

Posted - 2004-02-26 : 09:19:32
That's fine, we all started as a student, no need of being so strict

Try this, though there might be better way
select Str# from tb1 inner join tb2 on tb1.prod = tb2.prod group by Str# having count(Str#) =
(select count(Prod) from tb2)
Go to Top of Page
   

- Advertisement -