推薦網址: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;