一张表的一个列update到另外一张表的一个列:
update 表A a set a.userName = (select b.userName from 表B b where b.userID = a.userID and rownum = 1) where exists (select 1 from 表B c where c.userID = a.userID)
rownum = 1 是 为了确保子查询中只返回一个结果,避免表B中有多条userID相同的记录。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22569416/viewspace-1967084/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22569416/viewspace-1967084/