2014-12-06 61 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

相关问题