表A:
studentId表B:
studentId1,studentId2要求A.studentId=B.studentId1时, 将 相应的B.studentId2的值设给A.studentId实现这个功能的比较好的sql代码
studentId表B:
studentId1,studentId2要求A.studentId=B.studentId1时, 将 相应的B.studentId2的值设给A.studentId实现这个功能的比较好的sql代码
update A T1 set studentId=(select studentId2 from B where t1.studentId=studentId1)
where exists(select 1 from studentId2 where t1.studentId=studentId1)
update A T1 set studentId=(select studentId2 from B where t1.studentId=studentId1)
where exists(select 1 from B where t1.studentId=studentId1)
看看可不可以这样写:
update A T1 set studentId=nvl((select studentId2 from B where t1.studentId=studentId1),studentId)
就好像update A set A.studentId = '1';一样,无条件更新.