2014-12-06 43 views
-1

我有一個更新查詢,我試圖更新一個字段,但對於多個記錄,我正在嘗試一個連接,但它不起作用。下面我從select語句中得到多個值,但我認爲我的語法在下面不正確。如何使用另一個表上的連接更新Oracle中的表?

 UPDATE [email protected] x 
    INNER JOIN (
    select g.prev_perm_ret, g.itm_cd 
    from gm_prc_reg_prc_items g, [email protected] b 
    where g.itm_cd=b.stylecode 
    and b.storecode=00000 
    and g.prev_perm_ret<>b.listprice 
    and g.prev_perm_ret>g.ret_prc 
    and b.sellprice=b.listprice 
    ) y ON x.stylecode=g.itm_cd 
    SET x.listprice=y.prev_perm_ret 
+0

使用融爲一體。 – fabribara 2014-12-06 05:16:23

回答

0

MERGE INTO [email protected] x USING ( select g.prev_perm_ret, g.itm_cd from gm_prc_reg_prc_items g, [email protected] b where g.itm_cd=b.stylecode and b.storecode=00000 and g.prev_perm_ret<>b.listprice and g.prev_perm_ret>g.ret_prc and b.sellprice=b.listprice ) y ON x.stylecode=Y.itm_cd when matched then update set x.listprice=y.prev_perm_ret

+0

其實這並沒有工作,但無論如何感謝。我現在可以自己解決這個問題。 – niceguy 2014-12-06 05:22:54

+0

它必須工作。忘了添加更新命令 – fabribara 2014-12-06 14:27:10

相關問題