码迷,mamicode.com
首页 > 数据库 > 详细

数据库 批量查询结果作为更新的值

时间:2014-12-18 23:33:30      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:blog   http   ar   sp   strong   on   数据   div   art   

数据库批量更新。

业务需求:

需要将a表中 type为1 的数据的source_id更新为新的id。

因为之前的id是存储在p_server中,现在更新到了server_info表中

    1. update a set source_id = s.server_id  from   
    2. (select p_server.p_id,p_server.index_code,server_info.server_id   
    3. from p_server join server_info   
    4. on p_server.index_code = server_info.index_code) s where   
    5. a.source_id = s.p_id  
    6. and type = 1; 

数据库 批量查询结果作为更新的值

标签:blog   http   ar   sp   strong   on   数据   div   art   

原文地址:http://www.cnblogs.com/yishujiayuan/p/4172787.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!