update set from 語句用法 delete 多表刪除的使用 以及異常:table name "temp_new_tel" specified more than once


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM