如何在一条sql语句中把a,b表中满足关联条件的某列设为定值?

sheyu8 2003-10-20 05:21:41
如何把a,b表中满足一定关联条件的的所有学生的State同时都改为'UOA
下面这么做不对。
update A,B
set A.State='UOA'
set B.State='UOA'
where (A.class=B.class)and(A.name='小王')


...全文
155 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
伍子V5 2003-10-20
  • 打赏
  • 举报
回复
呵呵,有些问题
伍子V5 2003-10-20
  • 打赏
  • 举报
回复
update A
set A.State='UOA' from A,B
where (A.class=B.class)and(A.name='小王')

update B
set B.State='UOA' from A,B
where (A.class=B.class)and(A.name='小王')

go
txlicenhe 2003-10-20
  • 打赏
  • 举报
回复
一次只能更新一个表
update A
set A.State='UOA'
where A.name='小王'

update b
set b.State='UOA'
where b.name='小王'

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧