简单描述:现有一个网站,庞大的数据量。因为一些文章的删除,所以主键ID已经不连续了。有一些文章。想把他插入到现有的数据库里,一条条的修改现有数据库。  注意是修改,而不是增加。忽略文章分割等等问题。比如说update 表名 set 字段='文章1' where id=1
update 表名 set 字段='文章2' where id=3
update 表名 set 字段='文章3' where id=4
update 表名 set 字段='文章4' where id=8
......
ID在递增,但是不规律

解决方案 »

  1.   

    啥语法问题?分号?
    update 表名 set 字段='文章1' where id=1;
    update 表名 set 字段='文章2' where id=3;
    update 表名 set 字段='文章3' where id=4;
    update 表名 set 字段='文章4' where id=8;
      

  2.   

    你需要先 select id from 表名,然后再逐一UPDATE。
      

  3.   

    查找找具体的id
    select id from 表名
    然后再一条条的update.
      

  4.   

    加一个临时字段,如 ss int(1).
    然后:for($i=0;$i<10000;$i++){   mysql_query("update 表名 set 字段='文章 $i',ss=1 where ss=0 order by id asc limit 1");}最后删除 ss 字段.