'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 1:[1]
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;
Solution 2:[2]
You should avoid having spaces in table names, columns names, or field names.
Try this one:
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);
Best advice would be to rename all tables and columns using underscore instead of space: Concepto Presupuestal --> Concepto_Presupuestal. This will save you lots of problems.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rahul |
| Solution 2 | TylerH |
