现有个用户表,有两个字段:mobile 和 phone 记录有十几万条
现在要实现mobile所有记录都加到phone字段内,mobile字段记录全部删除.
copy mobile的记录到phone 里,和phone里面的记录加起来.
请各位大侠帮忙!!

解决方案 »

  1.   

    update tablename set phone=mobile+phone
    update tablename set mobile=''
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    分别执行....
      

  2.   

    以前是: 
    M  P
    11 88
    改变后要:
      p
    1188
    DELPHI里怎么实现最好,有十几万条数据哦
      

  3.   

    update tablename set phone=mobile+phone
      

  4.   

    我用ADO去做的.update tablename set phone=mobile+phone
    update tablename set mobile=''
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    分别执行....
    就是这么用的,现在是找最快捷的方法,代码怎么去实现??
      

  5.   

    adoquery1.sql.clear;
    adoquery1.sql.add('update tablename set phone=mobile+phone');
    adoquery1.execsql;
      

  6.   

    adoquery1.sql.clear;
    adoquery1.sql.add('update tablename set phone=mobile+phone');
    adoquery1.execsql;***************************************8
    这个是知道的,有十几万条的记录,每条记录都不一样.
    用adoquery1打开了这个表,顺序查找每一条的记录
    adoquery1.firstadoquery2.sql.clear;
    adoquery2.sql.add('update tablename set phone=mobile+phone where id=id号';
    adoquery2.execsql;adoquery1.next
    这样做出错了!!数据库出错了!
    还有什么方法去实现为好,数据很大!!
      

  7.   

    看不懂楼主上面的意思?????
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with adoquery1 do begin
      Close;
      SQL.Clear;
      SQL.Add('update tablename set phone=mobile+phone');
      ExecSQL;
      Close;
      SQL.Clear;
      SQL.Add('update tablename set mobile=null');
      ExecSQL;
    end;
    end;//这样就可以了...不过最好先备份原数据库
      

  8.   

    >>顺序查找每一条的记录这个~~~~
      

  9.   

    procedure TForm1.SpeedButton3Click(Sender: TObject);
    begin
      ADOQuery1.close;
      ADOQuery1.SQL.Text:='SELECT ID,PHONE,MOBILE from AMERCE';
      ADOQuery1.Open;
    end;procedure TForm1.SpeedButton1Click(Sender: TObject);
    var
      ID,
       phone,
         mobile:String;
    begin
        ADOQuery1.First;
       while not (ADOQuery1.Eof)  do
         begin
          Id:= ADOQuery1.FieldByName('id').AsString;
          phone:= ADOQuery1.FieldByName('phone').AsString;
          mobile:= ADOQuery1.FieldByName('mobile').AsString;
          phone:=phone+''+mobile;
          ADOQuery2.Close;
          AdOQuery2.SQL.Text:='update amerce set phone='''+ phone +''' where id='''+ id +'''';
          ADOQuery2.open;
          ADOQuery2.SQL.Text:='update amerce set mobile='' where id='''+ id +'''' ;
          ADOQuery2.ExecSQL;
          ADOQuery2.SQL.Text:='commit';
          ADOQuery2.ExecSQL;      ADOQuery1.Next;
         end;
    end;
    这样是报错的!无法执行,这???
      

  10.   

    procedure TForm1.SpeedButton3Click(Sender: TObject);
    begin
      ADOQuery1.close;
      ADOQuery1.SQL.Text:='SELECT ID,PHONE,MOBILE from AMERCE';
      ADOQuery1.Open;
    end;procedure TForm1.SpeedButton1Click(Sender: TObject);
    var
      ID,
       phone,
         mobile:String;
    begin
        ADOQuery1.First;
       while not (ADOQuery1.Eof)  do
         begin
          Id:= ADOQuery1.FieldByName('id').AsString;
          phone:= ADOQuery1.FieldByName('phone').AsString;
          mobile:= ADOQuery1.FieldByName('mobile').AsString;
          phone:=phone+''+mobile;
          ADOQuery2.Close;
          AdOQuery2.SQL.Text:='update amerce set phone='''+ phone +''' where id='''+ id +'''';
          ADOQuery2.Execsql;
          ADOQuery2.SQL.Text:='update amerce set mobile='' where id='''+ id +'''' ;
          ADOQuery2.ExecSQL;
          ADOQuery2.SQL.Text:='commit';
          ADOQuery2.ExecSQL;      ADOQuery1.Next;
         end;
    end;
    这个才是,不是open
      

  11.   

    〉〉这个才是,不是open
    没人跟你说过要open~~
      

  12.   

    你不要画蛇添足 〉〉引用一下~~
    看不懂楼主上面的意思?????
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with adoquery1 do begin
      Close;
      SQL.Clear;
      SQL.Add('update tablename set phone=mobile+phone');
      ExecSQL;
      Close;
      SQL.Clear;
      SQL.Add('update tablename set mobile=null');
      ExecSQL;
    end;
    end;//这样就可以了...不要加什么其他的代码尤其是while not (ADOQuery1.Eof)  do这样的
      

  13.   

    你不要画蛇添足 〉〉引用一下~~
    看不懂楼主上面的意思?????
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with adoquery1 do begin
      Close;
      SQL.Clear;
      SQL.Add('update tablename set phone=mobile+phone');
      ExecSQL;
      Close;
      SQL.Clear;
      SQL.Add('update tablename set mobile=null');
      ExecSQL;
    end;
    end;//这样就可以了...不要加什么其他的代码尤其是while not (ADOQuery1.Eof)  do这样的请问这样十几万条记录可以一次更改吗?? 这一段是更改那条记录呀???
      

  14.   

    update tablename set phone=mobile+phone//更改所有
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update语句也可以加条件,更改个别
    update tablename set phone=mobile+phone where xm=张三
      

  15.   

    我用的是ORACLE数据库,这句update不能执行update tablename set phone=mobile+phone//更改所有大侠们请指教!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~