<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-144  評論-80  文章-1  trackbacks-0

    UPDATE A.A3 = A.A3+B.B3 的問題

    表A 結(jié)構(gòu) : A1 , A2 ,A3
    表B 結(jié)構(gòu): B1,  B2,  B3
    其中 A1 ,B1 為PK ,切值相同 就是可以使用A1 = B1 了.

    請問用SQL 語句或過程該如何實現(xiàn)如下的功能???

    更新A 表的 A3 ,用A.A3 與B.B3之和更新.

    3>update A
    set A3 = (select A.A3 + B.B3 from B where A.A1 = B.B1) ;

    7>update (select a1,a3,b1,b3 from a,b where a1=b1) set a3=a3+b3

    開執(zhí)行計劃, 談?wù)撔适菦]有太多的意義的^_^..


    三樓的寫法與7樓的寫法得到的結(jié)果是不同的.

    三樓的寫法會更新所有記錄, 而7樓的寫法只修改兩者相交的相關(guān)記錄信息.

    7樓的寫法可以更加容易的控制這條update語句的執(zhí)行計劃, 不過要求B表必須在對應(yīng)的字段上有主鍵索引:) , 在B表在對應(yīng)字段上有主鍵索引的時候, 建議使用7樓的寫法.

    可以參考一下這個帖子^_^

    http://www.cnoug.org/viewthread.php?tid=44070
    (測試沒有成功..不知道怎么搞的.)
    參考了下面的:
    非常佩服。抱著學(xué)習(xí)的態(tài)度,重寫了一下三樓的,在沒有主鍵的情況,請指教:
    update a
    set a3=(select a3+b3 from b where a1=b1)
    where a1=(select b1 from b where a1=b1)
    如下:
    update con_eme_on20050309 a set a.con_price=(select a.con_price+(b.annuity-a.annuity)+(b.nojob-a.nojob)
    +(b.medicare-a.medicare)+(b.birthfee-a.birthfee)+(b.bruisefee-a.bruisefee) from con_eme_on200404 b
    where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.emp_base=(select b.emp_base from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.annuity=(select b.annuity from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.nojob=(select b.nojob from con_eme_on200404 bwhere a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.medicare=(select b.medicare from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.birthfee=(select b.birthfee from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.bruisefee=(select b.bruisefee from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.nojobbase=(select b.nojobbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.mediabase=(select b.mediabase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.birthbase=(select b.birthbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.bruisebase=(select b.bruisebase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)where a.emp_cod in(select b.emp_cod from con_eme_on200404 b
    where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)
    公積金:
    update con_eme_on20050309 a set a.con_price=(select a.con_price+(b.accumulation-a.accumulation) from con_eme_on200404 b
    where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulation=(select b.accumulation from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),
    a.accumulationbase=(select b.accumulationbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulationbase1=(select b.accumulationbase1 from con_eme_on200404 b
    where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)
    where a.emp_cod in(select b.emp_cod from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)

    28DE6CC0EDBBE9A61E23D9E9D46BB8A9.gif

    posted on 2005-03-10 10:22 小力力力 閱讀(2523) 評論(0)  編輯  收藏 所屬分類: ORACLE
    主站蜘蛛池模板: 美女视频黄a视频全免费| 亚洲人成电影在线观看青青| 国产成人精品日本亚洲语音| 免费做爰猛烈吃奶摸视频在线观看| 亚洲男人第一av网站| 最近免费中文字幕MV在线视频3| 久久精品国产亚洲AV不卡| 久久中文字幕免费视频| 亚洲精品无码久久久久| 久久伊人免费视频| 亚洲色偷偷偷网站色偷一区| 在线免费观看亚洲| 99热亚洲色精品国产88| 曰批全过程免费视频在线观看| 亚洲中文字幕无码久久2020| 国产免费午夜a无码v视频| 一级做a爰片久久毛片免费陪 | 日本一区二区在线免费观看| 亚洲AV中文无码乱人伦在线视色| 欧洲美女大片免费播放器视频| 久久亚洲国产精品123区| 免费国产黄网站在线观看| 亚洲国产成人超福利久久精品| 国产香蕉九九久久精品免费| 亚洲AV一区二区三区四区| vvvv99日韩精品亚洲| 在线观看人成视频免费无遮挡| 久久久久亚洲av无码专区导航 | 免费在线观看中文字幕| 9久热精品免费观看视频| 亚洲韩国在线一卡二卡| 日本高清免费aaaaa大片视频| 一级午夜a毛片免费视频| 4480yy私人影院亚洲| 日本无卡码免费一区二区三区| 天黑黑影院在线观看视频高清免费| 综合自拍亚洲综合图不卡区| 国产jizzjizz免费看jizz| 三年片在线观看免费大全电影| 亚洲色大成网站www| 国产日韩亚洲大尺度高清|