如何用SQL语句批量修改某个字段?

ddr527 2007-09-28 02:52:33
有表students如:
编号 班级 姓名
1  A   张三
2  A   李四
3  B   王五
4  B   赵六
5  A   郑七


现在要将全部A班的姓名改成“A-张三”的形式,请问SQL该如何写?
...全文
445 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
KaKaC 2008-04-05
  • 打赏
  • 举报
回复
zhengjie
Star8816 2008-03-20
  • 打赏
  • 举报
回复
如果是多個字段呢,應該如何編寫?
SoftwKLC 2007-09-28
  • 打赏
  • 举报
回复
---只更改A班人的姓名
Update students Set 姓名=班级+'-'+姓名 Where 班级='A'

---更改所有姓名
Update students Set 姓名=班级+'-'+姓名
dobear_0922 2007-09-28
  • 打赏
  • 举报
回复
update students set 姓名='A-'+姓名 where 班级='A'
dawugui 2007-09-28
  • 打赏
  • 举报
回复
有表students如:
编号 班级 姓名
1  A   张三
2  A   李四
3  B   王五
4  B   赵六
5  A   郑七


现在要将全部A班的姓名改成“A-张三”的形式,请问SQL该如何写?

update students
set 姓名 = 'A-' + 姓名
where 班级 = 'A'
Limpire 2007-09-28
  • 打赏
  • 举报
回复
update students set 姓名=班级+'-'+姓名 where 班级='A'
--OR
update students set 姓名='A-'+姓名 where 班级='A'
kk19840210 2007-09-28
  • 打赏
  • 举报
回复
update students set 姓名=班级+'-'+姓名

update students set 姓名=班级+'-'+姓名 where 班级='A'
wgzaaa 2007-09-28
  • 打赏
  • 举报
回复
update students set 姓名='A-'+姓名 where 班级='A'

34,576

社区成员

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

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