Search code examples
sqlsyntax-errorms-access-2010

Syntax error ( missing operator ) in query expression of


I have a table in Access 2010 and I want to make a kind INNER JOIN query from several tables I do is the following:

SELECT *
FROM (Archivo Maestro 
         INNER JOIN Concepto Presupuestal 
             ON Archivo Maestro.ID Concepto Presupuestal = Concepto Presupuestal.ID Concepto Presupuestal) 
         INNER JOIN asunto_estrategico 
             ON Archivo Maestro.ID Asunto Estrategico = asunto_estrategico.ID Asunto Estrategico;

but I get an error saying " Syntax error ( missing operator ) in query expression of 'Archivo Maestro.ID Concepto Presupuestal = Concepto Presupuestal.ID Concepto Presupuesta' and the parenthesis not think they are the problems that are there.


Solution

  • Problem is that your table names include space and so query parser/engine taking it as two different literal names. You should escape them using []. Also, notice that I have used table alias (am,cp,ae) for ease of reading. Your query should look like

    SELECT am.* FROM [Archivo Maestro] am
    INNER JOIN [Concepto Presupuestal] cp ON am.ID = cp.ID 
    INNER JOIN [asunto_estrategico] ae ON am.ID = ae.ID;