UPDATE table1 A INNER JOIN (SELECT id,COUNT(*) idcount FROM table2 GROUP BY id) B USING ...
dba.stackexchange.com