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

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

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

    Vincent.Chan‘s Blog

    常用鏈接

    統(tǒng)計(jì)

    積分與排名

    網(wǎng)站

    最新評(píng)論

    oracle update多表關(guān)聯(lián)

    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 了.

    請(qǐng)問用SQL 語句或過程該如何實(shí)現(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í)行計(jì)劃, 談?wù)撔适菦]有太多的意義的^_^..


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

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

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

    可以參考一下這個(gè)帖子^_^

    http://www.cnoug.org/viewthread.php?tid=44070
    (測試沒有成功..不知道怎么搞的.)
    參考了下面的:
    非常佩服。抱著學(xué)習(xí)的態(tài)度,重寫了一下三樓的,在沒有主鍵的情況,請(qǐng)指教:
    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)

    posted on 2006-02-22 13:03 Vincent.Chen 閱讀(229) 評(píng)論(0)  編輯  收藏 所屬分類: Database

    主站蜘蛛池模板: 亚洲午夜久久久精品影院| 亚洲AV无码乱码国产麻豆| 精品亚洲456在线播放| 在线观看免费中文视频| 亚洲AV一宅男色影视| 鲁丝片一区二区三区免费| 国产亚洲综合成人91精品 | 一区二区三区亚洲| 最好看最新的中文字幕免费| 久久精品国产亚洲AV麻豆网站| 91精品国产免费久久国语蜜臀| 亚洲专区中文字幕| 狼友av永久网站免费观看| 精品国产_亚洲人成在线| 免费成人黄色大片| 二个人看的www免费视频| 亚洲成AV人在线观看天堂无码| 久久免费区一区二区三波多野| 亚洲精品综合久久中文字幕| 成人黄动漫画免费网站视频 | 在线亚洲97se亚洲综合在线| 久久精品成人免费看| 亚洲第一永久在线观看| 日本媚薬痉挛在线观看免费| 一级毛片免费播放男男| 久久久久久亚洲精品中文字幕| 2021久久精品免费观看| 看亚洲a级一级毛片| 亚洲精品国偷自产在线| 97免费人妻无码视频| 深夜福利在线免费观看| 亚洲av福利无码无一区二区| 一二三四影视在线看片免费| 免费看美女午夜大片| 亚洲AV电影院在线观看| 午夜免费福利在线| 久久久久久久国产免费看| 一区二区三区视频免费观看| 91亚洲精品麻豆| 精品国产免费人成网站| 久久久久久亚洲Av无码精品专口|