SELECT t1.`id`, t1.`inn`, COUNT(t2.`id`) FROM `company` AS t1
LEFT JOIN `company` AS t2 USING (`inn`)
GROUP BY t1.`id`
UPDATE `company` AS t1
LEFT JOIN `company` AS t2 USING (`inn`)
SET t1.`cnt` = COUNT(t2.`id`)
UPDATE company AS t1
LEFT JOIN (
SELECT t2.inn, COUNT(t2.id) AS amount FROM company AS t2 GROUP BY t2.inn
) AS calc USING(inn)
SET t1.cnt = calc.amount;