Skip to content
Advertisement

Update Statement Sql Access Double Inner join

I have the following command

UPDATE tbl1
SET tbl1.val = 7
FROM ((tbl3 INNER JOIN tbl2 ON tbl3.ID = tbl2.ID) 
INNER JOIN tbl1 ON tbl1.ID = tbl2.ID) 
WHERE tbl3.ID = 2
AND tbl1.val = [val];

The innerjoins work as i use them elsewhere. However, i get the following error

“Syntax error (missing operator) in query expression”

I had this before and it turned out to be brackets because access is funny. However, i haven’t managed to figure this one out.

Advertisement

Answer

You should be able to use exists:

UPDATE tbl1
SET tbl1.val = 7
WHERE EXISTS (SELECT 1
              FROM tbl3 INNER JOIN
                   tbl2 ON tbl3.ID = tbl2.ID
              WHERE tbl1.ID = tbl2.ID AND 
                    tbl3.ID = 2
             ) AND
      tbl1.val = [val];
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement