0
votes

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.

2
ID Concepto Presupuestal Are these column names and table names with spaces? In Access, they must be [] enclosed. as [ID Concepto Presupuestal] or [Concepto Presupuestal] - Michael Berkowski

2 Answers

0
votes

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;
0
votes

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 advise would be to rename all tables and columns using underscore instead of space: Concepto Presupuestal --> Concepto_Presupuestal. This will save you lots of problems.