如何用一句sql修改auto_increment类型列的值?

laitysoft 2007-06-16 03:26:08

mysql数据库。

id这一列定义为auto_increment类型,由于某个原因,需要把id的值改变,
想用以下语句:
update stationmt set id=(select max(id)+1 from stationmt) where id=34;
结果报错,
ERROR 1093 (HY000): You can't specify target table 'stationmt' for update in FROM clause

若单独执行:
select max(id)+1 from stationmt;
update stationmt set id=35 where id=34;
都没有问题。

请问怎样写一句sql才能修改auto_increment类型列的值呢?
...全文
481 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaoyb 2007-06-19
  • 打赏
  • 举报
回复
mysql目前的版本还没办法实现
懒得去死 2007-06-18
  • 打赏
  • 举报
回复
select max(id)+1 from stationmt;

你这句有什么用呢
laitysoft 2007-06-18
  • 打赏
  • 举报
回复
取最大值加1,那应该怎么写?

56,677

社区成员

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

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