如何通过一个表的字段去更新另一个表的字段?

dxy860812 2013-03-28 10:57:14
一个表示学生信息表student 有学号 stuNo,姓名stuName等字段另一个表示学生成绩表score_english 有学号no,姓名name,成绩chengji等字段学生成绩表的学号是错误的 姓名是正确的 如何用学生姓名作为条件来更新成绩表中的学号(让该表的学生姓名及学号和信息表中的一致 )update score_english set no = student.stuNo where student.stuName = score_english.name我这么写 为什么不对呢?
...全文
95 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rotel-刘志东 2013-03-30
  • 打赏
  • 举报
回复
set sql_safe_updates=0; update score_english a,student b set a.no=b.stuno where a.stuname=b.name;
wwwwb 2013-03-29
  • 打赏
  • 举报
回复
是在MYSQL命令行下运行?
wwwwb 2013-03-29
  • 打赏
  • 举报
回复
SET SQL_SAFE_UPDATES=0;
dxy860812 2013-03-28
  • 打赏
  • 举报
回复
引用 1 楼 rucypli 的回复:
update score_english A,student B set A.no = B.stuNo where B.stuName = A.name
我用的是mysql 提示我 you are useing safe update mode and you tried to update a table wihtout a where that uses a key colunm to disable safe mode 我该如何更改设置?
rucypli 2013-03-28
  • 打赏
  • 举报
回复
update score_english A,student B set A.no = B.stuNo where B.stuName = A.name

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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