Search code examples
sqlsql-serverdatabasejoinrdbms

Where clause for all rows matches between tables


I have two tables like this:

table1                       table2

id  COL1    COL2        id  COL1    COL2
1   1   2               1   1         2
1   3   4               1   3         4
1                       1   5         6
1                       2   7         8
2   1   2               2   1         2
2   3   4               2   3         4
2   5   6               2   5         6
2   7   8               2   7         8

I want to find the id where it matches all rows for the id with second table

When I query in hana I am getting two id's

As only one id i.e 2 matches all rows with second table i am expecting id 2.

I tried all joins. Please help me.


Solution

  • I did it using string aggregation group by id.

    After that I compared columns using Id condition