table1 str_C
G_Code G_Name G_Amount //字段名
a1 b1 23
a2 b2 32
. . .
. . .Table2 STR_C
GCode GName GAmount //字段名
a1 b1 2
a1 b1 3
a2 b2 4
. . .
. . .现在是判断Table2 中的GCode字段中的每一行, 如果与Table1中的G_Code字段的值相等,那么把Table2表中GCode字段对应的GAmount字段的值加到Table1表中G_Code字段对应的G_Amount中。(注:Table1表中的记录较多,我试了几种方法但速度不是很理想,但有些方法不能在DelPhi中成功运行)
G_Code G_Name G_Amount //字段名
a1 b1 23
a2 b2 32
. . .
. . .Table2 STR_C
GCode GName GAmount //字段名
a1 b1 2
a1 b1 3
a2 b2 4
. . .
. . .现在是判断Table2 中的GCode字段中的每一行, 如果与Table1中的G_Code字段的值相等,那么把Table2表中GCode字段对应的GAmount字段的值加到Table1表中G_Code字段对应的G_Amount中。(注:Table1表中的记录较多,我试了几种方法但速度不是很理想,但有些方法不能在DelPhi中成功运行)
where Table1.GCode=Table2.GCode
group by GCode
Table1.G_code=Table2.Gcode;
select Table2.GAmount from table1,table2 where table1.G_code=table2.Gcode;
open table_cursor;
while @@FETCH_STATUS = 0
begin
fetch next from table_cursor into @GAmount
update table where table1.G_Amount=@GAmount
end
CLOSE table_cursor
DEALLOCATE table_cursor
from table1,table2
where table1.g_code=table2.gCode