Conceptually, I have the following two tables:
Table 1:
Table 2:
I'm looking to return only Groups which contain all Items in Table 2.
For example, for the above, the query would return:
As these groups contain Items 1, 2 & 3.
I was initially thinking something along these lines:
But this seems clunky and inefficient - is there a better way?
Thank you in advance for your time!
Lee
Table 1:
Code:
Group | Item
------+------
A | 1
A | 2
A | 3
A | 4
B | 1
B | 2
B | 5
C | 1
C | 2
C | 3
Table 2:
Code:
Item
-----
1
2
3
I'm looking to return only Groups which contain all Items in Table 2.
For example, for the above, the query would return:
Code:
Group
-----
A
C
I was initially thinking something along these lines:
Code:
SELECT Table1.Group
FROM Table1 INNER JOIN Table2 ON Table1.Item = Table2.Item
GROUP BY Table1.Group
HAVING Count(Table1.Item) = DCount("Item","Table2")
But this seems clunky and inefficient - is there a better way?
Thank you in advance for your time!
Lee