MySQL_update同一张表

update tb1 inner join
(select type, count(*) as cnt
from tb1 group by type)
as der using(type)
set tb1.cnt = der.cnt

原文地址:https://www.cnblogs.com/MarchThree/p/4641515.html