0

我需要在下面使用加入而不是子查询。谁能帮我用JOIN重写这个。

    update Table1
    set status = 'Edited' 
    where val_74 ='1' and status ='Valid'
    and val_35 is not null
    and (val_35,network_id) in 
    (select val_35,network_id from
    Table2 where val_35 is not null
    and status='Correct_1');



    update Table1 b SET (Val_12,Val_13,Val_14)=
    (select Val_12,Val_13,Val_14 from
      (select Val_35,network_id, Val_12, Val_13, Val_14
      from Table2
      where  Val_34 is not null
      and (REGEXP_LIKE(Val_13,'^[0-9]+$'))
      and (Val_14 is null or (REGEXP_LIKE(Val_14,'^[0-9]+$')))
      group by Val_35,network_id,Val_12,Val_13,Val_14
      )
      where  Val_35 = b.Val_35 and network_id = b.network_id and rownum=1
    )
    where status = 'PCStep2' and (regexp_like(Val_13,'[MSS]+') or regexp_like(Val_14,'[MSS]+'));

我用我较少的 SQL JOIN 知识尝试了很多。但得到多个错误。任何人都可以帮助我最早的查询。

提前衷心感谢

4

1 回答 1

0

实际上,您不能将 update 语句与 join 语句混合使用。一条update语句总是期望在命令之后恰好有一个表定义。update

-- ORA-00971: missing SET keyword
update orders o, customers c
set o.order_value = c.account_value
where o.cust_id = c.cust_id

-- works fine
update orders o
set o.order_value = (select c.account_value  
                     from customers c
                     where c.id = o.cust_id) 
于 2015-07-07T07:45:18.130 回答