200分,求解答

tutylove 2018-06-25 05:13:46
mysql里面有一个未知数据库,数据库里面有一张表ta,表里有多个字段,其中包含字段ID和key,怎么把id为1的对应key值更新到id为2的key值。
...全文
117 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tutylove 2018-06-26
  • 打赏
  • 举报
回复
引用 2 楼 xiewu91124 的回复:
update ta set `key`=(select a.key from (select `key` from ta where id=1) a) where id=2


哥们,你是对的,但执行的时候出现了 Unknown column 'id' in 'where clause' 是不是引号没有用对,怎么回事。
tutylove 2018-06-26
  • 打赏
  • 举报
回复
引用 4 楼 xiewu91124 的回复:
[quote=引用 3 楼 tutylove 的回复:]
[quote=引用 2 楼 xiewu91124 的回复:]
update ta set `key`=(select a.key from (select `key` from ta where id=1) a) where id=2


哥们,你是对的,但执行的时候出现了 Unknown column 'id' in 'where clause' 是不是引号没有用对,怎么回事。[/quote]
你的表结构里面有 id 这一列么?[/quote]

确实打错了字母
楓VS痕 2018-06-26
  • 打赏
  • 举报
回复
引用 3 楼 tutylove 的回复:
[quote=引用 2 楼 xiewu91124 的回复:]
update ta set `key`=(select a.key from (select `key` from ta where id=1) a) where id=2


哥们,你是对的,但执行的时候出现了 Unknown column 'id' in 'where clause' 是不是引号没有用对,怎么回事。[/quote]
你的表结构里面有 id 这一列么?
楓VS痕 2018-06-25
  • 打赏
  • 举报
回复
update ta set `key`=(select a.key from (select `key` from ta where id=1) a) where id=2
iamboy_11 2018-06-25
  • 打赏
  • 举报
回复
你干嘛要更新KEY的值呢?将key1对应的id值与key2对应的id值对调不就是了吗?

56,679

社区成员

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

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