两条sql变为一条sql-dba天空
开发需要写一个update ,把一张表中数据更新到另一张表,涉及到统计create table tmp as select provider_id,sum(score) score,sum(time_score) time_score from com_comment group by provider_id;
update pm_provider a inner join tmp b set a.score = b.score ,a.time_score=b.time_score where a.id = b. provider_id;
开发要求把两条sql合成一条
update pm_provider a inner join (select provider_id,sum(score) score,sum(time_score) time_score from com_comment group by provider_id) b set a.score = b.score ,a.time_score=b.time_score where a.id = b. provider_id;
页:
[1]