PLSQL问题请帮忙 谢谢!SQL code表1(table1)里的数据全部更新表2(table2)中的数据。如表1(table1)IDname01te
PLSQL问题请帮忙 谢谢!
- SQL code
表1(table1)里的数据全部更新表2(table2)中的数据。如表1(table1)ID name01 test102 test203 test304 test4表2(table2)ID name010203用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中。
[解决办法]
[解决办法]
