Update column based on sum of rows from another table by join The command I'm trying to find should do this:   

UPDATE table1 
SET table1.a = x 
WHERE table1.b = "something" AND table1.a IS NULL


The x is:  

SELECT SUM(c) from table2  
INNER JOIN table1  
ON table2.id=table1.id  
WHERE table1.b = "something" AND table1.a IS NULL  
GROUP BY table2.id;


I've tried some variations of the command but with no success.
Would appreciate any help in write the command properly.
Thanks.
One approach:

CREATE TEMPORARY TABLE x
    SELECT id, SUM(c) AS TheSum 
        FROM table2 ...;

UPDATE table1 JOIN x ON (table1.id = x.id)
    SET table1.a = x.TheSum
    WHERE table1.b = "something" AND table1.a IS NULL