oracle中三个表:
table_a(id_no,accept_no,beizhu)
table_b(id_no,accept_no)
table_c(id_no,accept_no)
把表 table_a中每条记录的id_no字段先到table_b中查询,如查到,就把table_a中这条记录的accept_no字段的值更新为table_b中相应记录中的accept_no的值,如在table_b中没查到,就到table_c中查,如查到,就把table_a中相应记录的accept_no字段的值更新为table_c中相应记录中的accept_no的值。是不是要用游标来处理?

解决方案 »

  1.   

    update table_a a
       set a.accept_no = nvl((select b.accept_no
                               from table_b b
                              where b.id_no = a.id_no),
                             (select c.accept_no
                                from table_c c
                               where c.id_no = a.id_no))
      

  2.   

    如在table_b中查到,就把table_a中记录的beizhu字段更新为"b",如在table_c中查到,就把table_a中记录的beizhu字段更新为"c"