Reputation: 107
I have something like this two tables:
A
____
| ID |
|----|
| 1 |
| 2 |
----
B
____ ______
| ID | TYPE |
|----|------|
| 1 | Q |
| 2 | W |
| 1 | W |
---- ------
Here i want to return 1 from table A cause it's linked with all possible types that exist in table B.
EDIT: I don't know before the query what all possible types are
Upvotes: 0
Views: 61
Reputation: 36523
You can always try this:
select id
from b
group by id
having count(distinct type) = (select count(distinct type) from b)
Upvotes: 4