表1(table1)里的数据全部更新表2(table2)中的数据。
如表1(table1)
ID   name
01   test1
02   test2
03   test3
04   test4
表2(table2)
ID   name
01
02
03
用PLSQL更新
想要表1(table1)和表2(table2)相同的ID更新。
表2(table2)中没有ID的用错误输出ID号码。 

解决方案 »

  1.   

    update table1 a 
    set a.name = (select b.name from table2 b where a.id = b.id and exists (select 1 from table2 where a.id = b.id));如果想要实现第二种功能,就需要使用游标来进行循环判断,看talbe2的id是否在table1中。
      

  2.   


    我就是不知道怎么样判断talbe1的id是否在table2中存在。
      

  3.   


    你的2个表,不就是根据ID关联的么,判断是否存在根据ID
      

  4.   


    我想输出没有更新的ID信息。也就是ID 04
      

  5.   

    select * from table2 where not exisits (select 1 from table1 where table2.id=table1.di)---这个结果就是没有更新的数据啊
      

  6.   

    如果用PLSQL语句来写的话。怎么样写法?谢谢
      

  7.   

    表1(table1)里的数据全部更新表2(table2)中的数据。
    如表1(table1)
    ID   name
    01   test1
    02   test2
    03   test3
    04   test4
    表2(table2)
    ID   name
    01
    02
    03如果用PLSQL语句来写的话。
    输出的信息是。
    >4件更新。
    >1件未更新。
    >正确更新完成任务。
    应该怎么写法。