0

Here is the problem:

UPDATE school_new 
  SET school_new.school_id = school.[School ID], 
      school_new.school_address = school.[School Address]
FROM school_new
INNER JOIN school on school_new.school_name = school.[School Name]

And I get this error and I can't figure out what is the problem

Syntax error (missing operator) in query expression 'school.[School ID] FROM school_new INNER JOIN school on school_new.school_name = school.[School Name]

2
  • No inner join for UPDATE queries Commented Jul 26, 2012 at 5:13
  • Why are you updating the same value twice? Commented Jul 26, 2012 at 5:23

4 Answers 4

4

There is a slight change in the update query with join on access

UPDATE school_new 
INNER JOIN school on school_new.school_name = school.[School Name]
  SET school_new.school_id = school.[School ID], 
      school_new.school_id = school.[School ID]
Sign up to request clarification or add additional context in comments.

Comments

1

List the tables and join condition before the SET keyword.

UPDATE school_new
INNER JOIN school
    ON school_new.school_name = school.[School Name]
SET school_new.school_id = school.[School ID]

In your example, you had school_new.school_id = school.[School ID] assigned twice; I did that SET only once. This point is important because if you list it twice, the db engine will throw an error...

Duplicate output destination 'school_new.school_id'.

Based on the update to your question ...

UPDATE school_new
INNER JOIN school
    ON school_new.school_name = school.[School Name]
SET school_new.school_id = school.[School ID], 
    school_new.school_address = school.[School Address]

1 Comment

Thank you, your answer works. I made a typo on my question. but using the join first solves the problem
0

I know this would sound strange but try to create a sample table e.g school_new_Test and in that do not give name with spaces and same way create duplicate table of school e.g school_ORG_Test in that also do not give spaces and then try the above query with new tables and collumn names without spaces.

Comments

-3

Generally, 'update' statements can't have a join. Use a nested query thus

update school_new
set school_new.school_id = (select school.[school ID]
from school where school.[school name] = school_new.school_name)

2 Comments

@ZafarYousafi: there can be a join in an update statement if the table to be updated is aliased (see stackoverflow.com/questions/1293330/sql-update-with-join). There is, however, no aliasing in the above question.
That's not true. You can use updates with joins no matter of the table is aliased or not. Plus, this question is about MS Access SQL, and the question you linked is not.

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.