本文介紹了根據另一個表結果更新的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想根據另一個表結果集更新臨時表.
I want to update a temp table based on another table result set.
任何建議.選擇查詢獨立工作.但我正在考慮與更新語句集成.
Any suggestions. The select query works independently. But I am thinking to integrate with the update statement.
UPDATE #person_membership_promo_ext
SET note_about=
(
select note_text
FROM note nt
INNER JOIN #person_membership_promo_ext per
ON per.person_id=nt.main_ref_id
and per.membership_type='P'
and note_id=(select MAX(note_id)from note nt_1
where nt_1.main_ref_id=per.person_id)
)
推薦答案
給你,
Update per
set per.note_about = nt.note_text
FROM note nt
INNER JOIN #person_membership_promo_ext per
ON per.person_id=nt.main_ref_id
and per.membership_type='P'
and note_id=(select MAX(note_id)from note nt_1
where nt_1.main_ref_id=per.person_id)
我希望這會有所幫助!
這篇關于根據另一個表結果更新的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!