Mysql update adding subquery field value to field I want to update a field adding it the value of a subquery field.

I'm trying this:

UPDATE table a 
SET a.field=(a.field+b.subfield) 
INNER JOIN (SELECT subid, subfield FROM subtable WHERE ..... ) AS b 
ON a.id = b.subid 
WHERE ... 


but I'm getting the syntax error.

How is the correct syntax for this operation?
Please move the SET a.field=(a.field+b.subfield) after ON a.id = b.subid and before WHERE

So, the query should look like this:

UPDATE table a 
INNER JOIN (SELECT subid, subfield FROM subtable WHERE ..... ) AS b 
ON a.id = b.subid 
SET a.field=(a.field+b.subfield) 
WHERE ... 


Give it a Try !!!