1

hello and thanks in advance for any help.

I am getting an error: 'Syntax Error (missing operator) in query expression' and I do not know why... any ideas?

This is my query:

 UPDATE 
table1

SET 
table1.country_name = table2.COUNTRY,
table1.city = table2.CITY ,
table1.state = table2.STATE 

FROM
 ( table1 
inner join
table2 
ON
 table2.SITE_ID = table1.SiteID )

where
table1.country_name is null;
0

2 Answers 2

5

There is no FROM clause in an UPDATE query in Access/Jet SQL:

UPDATE table1 INNER JOIN table2 ON table1.SiteID = table2.SITE_ID
SET table1.country_name = table2.COUNTRY,
    table1.city = table2.CITY ,
    table1.state = table2.STATE 
WHERE table1.country_name is null;
Sign up to request clarification or add additional context in comments.

4 Comments

Using UPDATE....FROM is perfectly acceptable look at the definition here msdn.microsoft.com/en-us/library/ms177523.aspx
@John: That link is to Transact-SQL (ie, MS SQL Server). This question is tagged with ms-access. Different (more limited) syntax. See link in my answer.
I am using Microsoft Access 2007... if that could have anything to do with the error...
@tyler: The fact that you are using Access is indeed what is causing the error. The version of Access is not relevant in this situation.
2

Lose the parenthesis around the joined tables. In addition I would personally make an alias for table1 and table2 and reference the table1 alias in the update. Like this:

UPDATE t1
SET 
  t1.country_name = t2.COUNTRY,
  t1.city = t2.CITY,
  t1.state = t2.STATE 
FROM table1 t1 
INNER JOIN table2 t2 ON t2.SITE_ID = t1.SiteID
WHERE
  t1.country_name is null;

2 Comments

@tylercomp Then your omitting telling us something as I just ran a test scenario on my SQL Server.
Check the tags. The missing information you're asking about is ms-access.

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.