update set from where

update t1  set age=t2.age,name=t2.name from  t2 where t1.id=t2.id;
update t_company_info
set score = b.score,
tech_score = b.tech_score,
project_score = b.project_score,
service_score = b.service_score,
product_score = b.product_score,
efficiency_score = b.efficiency_score,
evaluate_no = a.evaluate_no + 1
from t_company_info a inner join
(select c.company_id,
avg(c.score) as score,
avg(c.tech_score) as tech_score,
avg(c.project_score) as project_score,
avg(c.service_score) as service_score,
avg(c.product_score) as product_score,
avg(c.efficiency_score) as efficiency_score
from t_evaluate_company c
group by c.company_id
)b
on a.id = b.company_id
and a.id =1;
posted @ 2017-01-11 14:31  esther-qing  阅读(353)  评论(0编辑  收藏  举报