推荐网址:https://www.cnblogs.com/ShaYeBlog/p/10893963.html
下面这两条sql语句的效果是一样的
update t_score_grent aa
set usable_score=aa.usable_score + bb.pay_score
from (
select score_grent_id, pay_score from t_score_settel_detail where score_settel_id = '77'
) bb
where aa.score_grent_id::varchar = bb.score_grent_id
and exists(
select 1
from t_score_settel_detail
where aa.score_grent_id::varchar = score_grent_id
and score_settel_id = '77'
)
update t_score_grent
set usable_score=aa.usable_score + tssd.pay_score
from t_score_grent aa
left join t_score_settel_detail tssd on aa.score_grent_id::varchar = tssd.score_grent_id
where tssd.score_settel_id = '0';
delete 多表删除的使用:https://blog.csdn.net/hevenue/article/details/70264356
以及异常:table name "temp_new_tel" specified more than once解决办法:
https://blog.csdn.net/qq_22310551/article/details/83181241
将更新sql改成这样就可以了
delete from temp_new_tel using temp_tel where temp_new_tel.telphone=temp_tel.telphone;