表1
单位名称 盒数1 金额1表2
单位名称 收入数量 收入金额用表2中的收入数量替换表1中的盒数1 ,收入金额替换表1中的金额1
单位名称 盒数1 金额1表2
单位名称 收入数量 收入金额用表2中的收入数量替换表1中的盒数1 ,收入金额替换表1中的金额1
解决方案 »
- pchar!唉,原来pchar不仅从dll中返回不行,从类中的实例中返回也不行
- 请教读取User.db好友列表文件
- 请教cuDBActns.dcu是什么控件,可有For Delphi 7版本的?
- 终于找到了IActiveScript的声明 AXScript.pas
- 头大的问题。窗口上有两个DateTimePicker控件需要在编程中限制前一个日期不可以超过后一个。有人实现过么?
- 查汉字拼音
- 请教:自己定义的ado记录集(Recordset)下定位某一条记录的命令是什么?
- 请教各位,那里有准备考研的英语学习网站,或比较好的考研英语学习教材?
- tapi的问题,非常紧急!
- 好控件。。。。。。
- 100分求教!动态生成控件是不是要先有这个控件!!
- 如何从内存中释放所有窗口?急!!!!
query1.sql.text := 'select * form table1'
query1.open;
query2.close;
query2.sql.text := 'select * form table2'
query2.open;
while not query1.eof do
begin
query1.edit;
query1.fieldbyname('盒数1').asstring := query2.fieldbyname('收入数量).asstring;
query1.fieldbyname('金额1').asstring := query2.fieldbyname('收入金额').asstring;
query1.post;
query1.next;
query2.next;
end;
这是参考,细节你自己处理
select 单位名称,收入数量,收入金额 from 表2不太明白你到底要做什么,我猜测可能是这样。
set 盒数1=(select收入数量 from 表2 b where a.单位名称=b.单位名称),金额1=(select 收入金额 from 表2 b where a.单位名称=b.单位名称)
where a.单位名称=b.单位名称
set 盒数1=表2.收入数量,
金额1 = 表2.收入金额
from 表2
where 表1.单位名称=表2.单位名称
set 盒数1=表2.收入数量,
金额1 = 表2.收入金额
from 表1,表2
where 表1.单位名称=表2.单位名称
query1.sql.text := 'select * form table1'
query1.open;
query2.close;
query2.sql.text := 'select * form table2'
query2.open;
while not query1.eof do
begin
query2.first;
while not query2.eof do
begin
if trim(query1.fieldbyname('单位名称 ').asstring) = trim(query1.fieldbyname('单位名称 ').asstring) then
begin
query1.edit;
query1.fieldbyname('盒数1').asstring := query2.fieldbyname('收入数量).asstring;
query1.fieldbyname('金额1').asstring := query2.fieldbyname('收入金额').asstring;
query1.post;
break;
end else
query1.next;
query2.next;
end;
end;这样可能速度会慢一些,你可以用Locate定位会快上些