update law_zlaw as a inner join (select count(v_id) as sum,z_id from law_vsion GROUP BY z_id) as b on a.z_id=b.z_id set count_zid = b.sum