现有个用户表,有两个字段:mobile 和 phone 记录有十几万条
现在要实现mobile所有记录都加到phone字段内,mobile字段记录全部删除.
copy mobile的记录到phone 里,和phone里面的记录加起来.
请各位大侠帮忙!!
现在要实现mobile所有记录都加到phone字段内,mobile字段记录全部删除.
copy mobile的记录到phone 里,和phone里面的记录加起来.
请各位大侠帮忙!!
解决方案 »
- 请教这样的代码。在dll文件中指定位置写‘字符串’,和读取它。
- Printers如何设定纸张
- 是不是Delphi只能引用提供ocx类的控件,不能引用提供.dll类的控件?
- 问个简单问题:如何使combobox的items只允许用户选择,不允许用户修改?
- 请教:如何让非模态对话框始终显示在最上面
- 如何处理clientSocket OnRead事件中指令的顺序执行(同步)?
- 关于WISE 9 打包的问题.
- 基于socket的即时通讯 用Delphi 我一点都不会
- 我的D,E盘莫名其妙的不见了,只看到C盘,重装98,还是找不到?
- delphi xe版本調試怎麼設置
- 如何向打开的Word文档中插入保存在文本文件中的VBA脚本,并运行它?
- 找二个第三方控件!!!
update tablename set mobile=''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
分别执行....
M P
11 88
改变后要:
p
1188
DELPHI里怎么实现最好,有十几万条数据哦
update tablename set mobile=''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
分别执行....
就是这么用的,现在是找最快捷的方法,代码怎么去实现??
adoquery1.sql.add('update tablename set phone=mobile+phone');
adoquery1.execsql;
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
这样做出错了!!数据库出错了!
还有什么方法去实现为好,数据很大!!
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;//这样就可以了...不过最好先备份原数据库
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;
这样是报错的!无法执行,这???
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
没人跟你说过要open~~
看不懂楼主上面的意思?????
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这样的
看不懂楼主上面的意思?????
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这样的请问这样十几万条记录可以一次更改吗?? 这一段是更改那条记录呀???
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
update语句也可以加条件,更改个别
update tablename set phone=mobile+phone where xm=张三