 |
我不甚了解这位朋友的意思,我理解为将表2的内容追加到表1中。假设表1、表2中均含有X、Y字段,下面是源代码:
PUBLIC a, b
SELECT 表2
FOR i=1 to RECCOUNT()
GOTO i
a=x
b=y
INSERT INTO 表1 (x,y) VALUES (a,b)
ENDFOR
若仍有问题请与我联系。
deviel的意见:
我想应该是这样:
设表1有a,c字段,表2有a,c,我想应该是这样的
sele 1
use 表1*以下简称b1,在这个表里先建一个c的字段
sele 2
use 表2*以下简称b2
sele 1
for i=1 to reccount()
sele 3
go top
loca for a=a->a
if forund()
sele 1
repl c with b->c
endif
go i
skip
endfor
阿飞(夏小飞)的意见:
我的解决方案:
这应该是一个用BB表x字段来更新AA表x字段的问题,首先在A表和B表中应该都有一个序号字段
,假设为“id”
代码如下:
sele a
use bb
index on id tag id
sele b
use aa
index on id tag id
upda on id from bb repl aa.x with bb.x
close all
代码结束。
注意:BB表是更新的源,AA表是更新的目标。id在表中必须唯一。
华人的意见:
use a
sele 2
use b
repl all x with a.x
for a.recn()=b.recn()
Micheal的意见:
设A表中有字段A1,A2, B表中有字段A1,A2, 记录都相同,要将A表的A1字段的值拷贝到B表中的A1字段,可执行一次循环。
use A in 0
sele a
index on A1 tag A_A1
use B in 0
index on A1 tag B_A1
sele a
set rela to A1 into B
do whil !eof()
repl B.A1 with A1
skip
enddo
set rela to
clos tabl all
Micheal的意见:
use a in 0
use b in0
sele a
index on A1 tag a_A1
sele b
index on A1 tag b_A1
sele a
set rela to A1 into b
do whil !eof()
repl b.A1 with A1
skip
enddo
clos tabl all
return
此问题由Chiman回答。
附加关键字:编程, 源程序, programming, source code, FoxPro/Visual FoxPro, Foxbase, dBase, xbase, FoxPro, VFP, Visual FoxPro, 数据库, database, query。
|