Skip to content
Advertisement

SQL Find duplicate sets

given this Schema:

tblSetItem.SetID is a FK into the tblSet Table.

Some data:

tblSet

tblSetItem

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?

Advertisement

Answer

You can use xml support to create a comma separated list (cf this answer: https://stackoverflow.com/a/1785923/215752). For this case I don’t care about the form so I leave the starting comma in.

Note, I couldn’t test this right now so I might have a typo…

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement