0

I'm getting a syntax error within MS Access VBA whereas the same line perfectly works fine in SQL Server:

UPDATE a 
SET a.Result = b.Result, a.Part = b.Part 
FROM tbl_Parts a 
JOIN ( SELECT b.* FROM tbl_Parts b WHERE b.ID = 180) b 
ON b.Part_Nr = a.Part_Nr;

I'm trying to use one row as a template and copy it's content to already existing other rows from the same Part-ID.

4
  • Access and SQL Server don't use the same dialect of SQL. Commented Jul 31, 2022 at 15:20
  • In Msacess the SET comes after the JOIN. The syntax is UPDATE TBL1 INNER JOIN TBL2 ON TBL1.X = TBL2.Y SET TBL1.P = TBL2.Q Commented Jul 31, 2022 at 15:31
  • @JonathanWillcock: Is there any documentation about the differences? Commented Aug 1, 2022 at 6:18
  • Not that I know of - for my own purposes I have a list of standard syntax for UPDATE/DELETE on joins for the DBs that I most familiar with, but I don't know of any site that gives a complete comparison. Commented Aug 1, 2022 at 10:48

1 Answer 1

1

Consider:

UPDATE tbl_Parts AS a 
INNER JOIN (SELECT * FROM tbl_Parts WHERE ID = 180) AS b
ON b.Part_Nr = a.Part_Nr
SET a.Result = b.Result, a.Part = b.Part;
Sign up to request clarification or add additional context in comments.

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.