0

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.

1
  • 3
    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] Commented May 26, 2015 at 20:15

2 Answers 2

0

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;
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.