sql 兩表查詢后 更新某表中部分字段


這是上一個sql更新某表字段的一個延伸,在更新表數據時,實際上會有多表數據查詢場景,查詢后,只需要更新某一個表中的數據,以下提供兩個方法,

第一種使用update 兩表查詢

update api_manage_apicollectioninfo_copy a, api_manage_apicollectionmanage b   set a.header=replace(a.header,'XXXDDD','zhangjun')  WHERE a.api_collection_id=b.id and b.project_id=4 and b.creator_id=12

 第二種使用inner join 

update api_manage_apicollectioninfo_copy a INNER JOIN api_manage_apicollectionmanage b   ON  a.api_collection_id=b.id  set a.header=replace(a.header,'zhangjun','$zhangjun12')  WHERE b.project_id=4 and b.creator_id=12

  


免責聲明!

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



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