G
guest5006
Im using Access 97 (anyone still remember 97?) and the query is complainingabout a "syntax error missing operator". I suspect it has something to do with using two SELECTs for the INNER JOIN. INNER JOIN expects table names but I thought a SELECT returns a table. It is possible to assign a table name to each of the 2 SELECTs and then do a INNER JOIN?
SELECT * FROM Card WHERE Card.pk IN
(
(SELECT DISTINCT Card_Tag.cardFK FROM Card_Tag
WHERE Card_Tag.tagFK IN (9,6)
GROUP BY Card_Tag.cardFK
HAVING COUNT(Card_Tag.cardFK) = 2)
INNER JOIN
(SELECT DISTINCT Card_Source.cardFK FROM Card_Source
WHERE Card_Source.sourceFK IN (8,2,4)
GROUP BY Card_Source.cardFK
HAVING COUNT(Card_Source.cardFK) = 3)
ON Card_Tag.cardFK = Card_Source.cardFK
);
Table Card_Tag joins tables Card and Tag. Table Card_Source joins tables Card and Source.
SELECT * FROM Card WHERE Card.pk IN
(
(SELECT DISTINCT Card_Tag.cardFK FROM Card_Tag
WHERE Card_Tag.tagFK IN (9,6)
GROUP BY Card_Tag.cardFK
HAVING COUNT(Card_Tag.cardFK) = 2)
INNER JOIN
(SELECT DISTINCT Card_Source.cardFK FROM Card_Source
WHERE Card_Source.sourceFK IN (8,2,4)
GROUP BY Card_Source.cardFK
HAVING COUNT(Card_Source.cardFK) = 3)
ON Card_Tag.cardFK = Card_Source.cardFK
);
Table Card_Tag joins tables Card and Tag. Table Card_Source joins tables Card and Source.