資料庫 批量查詢結果作為更新的值,批量查詢結果

來源:互聯網
上載者:User

資料庫 批量查詢結果作為更新的值,批量查詢結果

資料庫批次更新。

業務需求:

需要將a表中 type為1 的資料的source_id更新為新的id。

因為之前的id是儲存在p_server中,現在更新到了server_info表中

update a set source_id = s.server_id  from (select p_server.p_id,p_server.index_code,server_info.server_id from p_server join server_info on p_server.index_code = server_info.index_code) s where a.source_id = s.p_idand type = 1;


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.