日期:2014-05-19  浏览次数:20454 次

求SQL语句,比较简单!
表A:

name    
dept

表B:

name
dept

我想用一条update语句修改掉所有表B的dept,从表A里查到,name字段相互对应!

------解决方案--------------------
update b
set dept=a.dept
from 表A a inner join 表b b
on a.name=b.name
------解决方案--------------------
update b
set dept = a.dept
from b,a
where b.name = a.name
------解决方案--------------------
update b
set dept=a.dept
from 表A a inner join 表b b
on a.name=b.name

------解决方案--------------------
update b set dept = a.dept from tab1 as a inner join tab2 as b
on (a.name = b.name)
------解决方案--------------------
update b set dept = a.dept from (select * from tab1 as a inner join tab2 as b
on a.name = b.name)

------解决方案--------------------
你倆表的dept 的數據類型是啥?

試下這個

Update B Set dept = Left((Select dept From A Where name = B.name), 8000)
------解决方案--------------------
楼主把varchar改为text试试!