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