Reputation:
Does anyone know how to Filter from two tables(A,B) all the tuples which are a full subset of the other table?
So I want to filter all the matrnr from Table A which contains both of the values of Table B.
So the result should be: 4321
Example:
TABLE A:
matrnr | lvanr |
---|---|
4321 | 1234 |
4321 | 4321 |
1234 | 5431 |
TABLE B:
lvanr |
---|
1234 |
4321 |
Thanks for help :))
Upvotes: 0
Views: 63
Reputation: 32609
You can outer join the tables and filter on matching counts, does the following work for you?
select a.matrnr
from TablaA a
left join TableB b on a.ivanr = b.ivanr
group by a.matrnr
having Count(a.matrnr) = Count(b.ivanr) ;
Upvotes: 1