SQL Find duplicate sets
- by Aheho
given this Schema:
table tblSET
SetID int PK
SetName nvarchar(100)
Table tblSetItem
SetID int PK
ItemID int PK
tblSetItem.SetID is a FK into the tblSet Table.
Some data:
tblSet
SetID SetName
1 Red
2 Blue
3 Maroon
4 Yellow
5 Sky
tblSetItem
SetID ItemID
1 100
1 101
2 100
2 108
2 109
3 100
3 101
4 101
4 108
4 109
4 110
5 100
5 108
5 109
I'd like a way to identify which sets contain the same items. In the example above Red and Maroon contain the same items (100,101) and Blue and Sky contain the same values (100,108,109)
Is there a sql query which would provide this answer?