I have two tables. Table A
and Table B
. Both are connected with a many-to-many relationship.
Table A:
ID
---
1
2
Table B:
ID
---
3
4
Table AB:
ID | A_ID | B_ID
----------------
5 | 1 | 4
6 | 1 | 3
7 | 2 | 3
I want to get the list of ID
s from table B
which have a relation to a list of ID
s of table A
.
Example from the above tables:
I want to get all B
s which have a relation to table A
ID
1 and ID
2. I get then ID
3 has to both ID
s of table A
.
How could I do this with an SQL query ?