日期:2014-05-17  浏览次数:20665 次

PLSQL问题请帮忙 谢谢!
SQL code

表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号码。 



------解决方案--------------------


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中。

------解决方案--------------------
探讨
引用:
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是否在ta……

------解决方案--------------------
探讨
引用:

引用:
引用:
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));……