日期:2014-05-18  浏览次数:20565 次

SQL新手求更新语句
有两张表sys_orgmenber和sys_user
我现在想更新sys_orgmenber中的supervisorFullName字段,而这个字段的值是sys_user中supervisorFullName字段的值
这两张表有一个关联sys_orgmenber中的member=sys_user中的fullname
大约数据是3500左右
求语句
顺便问下,不写循环能一次更新多条数据吗?
如下是我自己写的。
update sys_orgmenber set supervisorFullName = 
(select supervisorFullName from sys_user) where member in (select fullname from sys_user)

------解决方案--------------------
期待高手。。
------解决方案--------------------
SQL code

update a
set a.supervisorFullName = b.supervisorFullName
from sys_orgmenber a join sys_user b on a.member = b.fullname

------解决方案--------------------
SQL code


update sys_orgmenber set supervisorFullName =  b.supervisorFullName from sys_orgmenber a inner join sys_user b on a.member = b.fullname

------解决方案--------------------
update sys_orgmenber set supervisorFullName = n.supervisorFullName
from sys_orgmenber m , sys_user n
where m.member = n.fullname

------解决方案--------------------
SQL code
update
 a
set
 supervisorFullName = b.supervisorFullName
from
 sys_orgmenber a join sys_user b on a.member = b.fullname

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

update sys_orgmenber set supervisorFullName = a.supervisorFullName
from sys_user as a
where a.fullname=sys_orgmenber.member
------解决方案--------------------
SQL code
update sys_orgmenber set supervisorFullName = A.supervisorFullName
from sys_orgmenber A , sys_user B
where A.member = B.fullname

------解决方案--------------------
update sys_orgmenber set supervisorFullName = n.supervisorFullName
from sys_orgmenber m , sys_user n
where m.member = n.fullname

------解决方案--------------------
SQL codeupdate
 a
set
 supervisorFullName = b.supervisorFullName
from
 sys_orgmenber a join sys_user b on a.member = b.fullname 

------解决方案--------------------
update sys_orgmenber set sys_orgmenber.supervisorFullName=sys_user.supervisorFullName

from sys_user where sys_orgmenber.member=sys_user.fullname

本人也是新手,希望此帖有所指导。