Skip to content
Advertisement

How to compare rows as lists in SQL?

I have a many to many table which has 3 primary keys shown below :

I want to compare rows as lists,

For Example :

table1 would be :

So what I’d like to achive is to compare my table filtered by key_1 and find duplicate list of rows.

So in this scenerio,

returns 3 rows (row1, row2, row3) and

also returns 3 rows (row4, row5, row6)

And as you see above, first result of 3 rows has same key_2 & key_3 values with the second result of 3 rows.

So how can I query this, get rows as lists and compare them?

I know that this question looks something stupid but please, I’d very glad if you help me. Thanks in advance 🙂

Advertisement

Answer

You can search for unmatched rows of a full outer join.

For example the following query finds any difference between group 10 and 11:

If the query returns no rows, then the groups are identical.

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