现在我有这样一个需求
表A id字段为自增字段
表B 有一个file_id字段,有816条数据,要求把这个字段从A表中id字段最大值开始自增,比如A表现在最大值为100
B表这个字段就从101开始
应该如何写语句呢
表A id字段为自增字段
表B 有一个file_id字段,有816条数据,要求把这个字段从A表中id字段最大值开始自增,比如A表现在最大值为100
B表这个字段就从101开始
应该如何写语句呢
解决方案 »
- 救命啊,各位大虾,要出人命了!关于mysql to mssql并且还有编码问题,详细请进。。。100分
- VC连接不上mysql数据库是什么原因?
- mysql自己生成的seq_表怎么回事?
- 高分讨论MySQL主服务器当机问题!
- C -> mysql
- mysql version 4.0.13-nt,能不能用一个sql语句实现这样的select
- mysql好像没有存储过程是吧?
- MySQL 安装问题
- 求助:MYSQL 中的replace函数怎么才能不区分大小写?
- mysql 结合shell脚本时,如何控制输入的格式
- windows客户端如何通过程序访问unix/linux下的数据库(如mysql,postgresql,oracle)
- mysql级别的负载均衡
select auto_increment from information_schema.tables where table_name="t_name"结果再加一就是你要的b表id了
select auto_increment from information_schema.tables where table_schema='库名' and table_name='表A';
insert into B表(field_id,其它)
select A表.auto_increment+100 ,其它
from A表
alter table B表 AUTO_INCREMENT=(select last_insert_id()+1);