UPDATE only if COUNT from another table is not zero I update a table by counting the FK from another table as

UPDATE table1 
SET number = number +
(
SELECT COUNT(*) FROM table2 
WHERE  table1.id=table2.id
)


table1 is a big table, and I want to make the UPDATE only if COUNT has found something. In other words, I do not want to make the UPDATE for number=0.
Derive a table of counts by id from table2, join the results to table1 and use that join in the UPDATE statement:

UPDATE
  table1 AS t1
  INNER JOIN
    (
      SELECT
        id,
        COUNT(*) AS cnt
      FROM
        table2
      GROUP BY
        id
    ) AS t2 ON t1.id = t2.id
SET
  t1.number = t1.number + t2.cnt
;


The above statement will affect only the table1 rows that have matches in table2.