Nested or Sub query not working in Access 2003
Posted on 2007-10-16
Hi. My brain is fried. I have some funky queries joined together as separate queries in Access that work just fine (the explanation for their funkiness is far too long to go into here). When I try to combine the queries into a single query (using "nested" or "sub" queries- not sure which term is correct), I receive a "Syntax error in FROM clause" message, and the "INNER" after L3Map is highlighted when I return to SQL view in the Access query window.
Can anyone tell me why this isn't working? Any help would be very appreciated!
SELECT RowMap.Sort FROM [SELECT DISTINCT DATA2.ID, LabelTable.Sort AS Sort FROM DATA2 RIGHT JOIN LabelTable ON DATA2.FR_EXT2 = LabelTable.Value
WHERE LabelTable.Scale='SatScale' AND LabelTable.Sort In (3,1)] As RowMap
LEFT JOIN [SELECT ColMap.Sort, ColMap.ID
FROM [SELECT DISTINCT DATA2.ID, LabelTable.Sort AS Sort FROM DATA2 INNER JOIN LabelTable ON DATA2.OMC_YN= LabelTable.Value
WHERE LabelTable.Scale = 'OMC_YN' AND LabelTable.Sort In (2)] As L3Map
INNER JOIN [SELECT DISTINCT DATA2.ID, LabelTable.Sort AS Sort
FROM DATA2 INNER JOIN LabelTable ON DATA2.RV_BODY= LabelTable.Value
WHERE LabelTable.Scale = 'RV_BODY' AND LabelTable.Sort In (2,1)] As ColMap ON L3Map.ID = ColMap.ID]
ON RowMap.ID = ColMap.ID
GROUP BY RowMap.Sort