Home » excel » SQL/Excel/VBA – UPDATE query: 'Syntax Error (missing operator) in query expression'

SQL/Excel/VBA – UPDATE query: 'Syntax Error (missing operator) in query expression'

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have very simple query that is not working and I get error:

‘Syntax Error (missing operator) in query expression Tabela2.SALES2
FROM Tabela2’

Here is the code:

UPDATE Tabela1 
SET Tabela1.SALES = Tabela2.SALES2 
FROM Tabela2 
WHERE Tabela1.ID = Tabela2.ID

I want to run this query from VBA/Excel on Acces database (2007). Others queries with e.g. SELECT are working fine, so the problem is only with the query. And I really don’t know why it is not working.

How to&Answers:

An UPDATE query using FROM is possible in SQL Server, but not in MS Access. Use this instead:

UPDATE Tabela1 INNER JOIN Tabela2 ON Tabela1.ID = Tabela2.ID 
SET Tabela1.Sales = [Tabela2].[Sales2];

Answer:

UPDATE Tabela1
SET Tabela1.SALES = Tabela2.SALES2
FROM Tabela1,Tabela2
WHERE Tabela1.ID = Tabela2.ID

Answer:

try this

UPDATE Tabela1 
SET Tabela1.SALES = Tabela2.SALES2 
FROM Tabela1 
INNER JOIN Tabela2 
WHERE Tabela1.ID = Tabela2.ID

Answer:

Update TABLE2, TABLE1
SET TABLE2.SALES2 = TABLE1.SALES
WHERE TABLE2.ID=TABLE1.ID

hey friends try this 100% working. As per poonam FROM statement is not possible and its true but no need to inner join and make your query slow down.
This SQL Query will run on MS Access only.