检查 vfp 中不同表中的 2 个相同数据,因此我可以将其放在 IF 语句中



如果table_A.firstnametable_B.firstname中有完全相同的数据,则会出现一个消息框。 我想知道这是什么代码?

它就像:

if trim(table_A.firstname) == trim(table_B.firstname)

这将找到table_B.firstname中的所有重复项

close all
set talk off
use table_a in 0
use table_b in 0
sele table_a
scat memv
do while !eof()
sele table_b
scan for firstname=m.firstname
wait wind allt(m.firstname)+" RecNo="+allt(str(recno()))
endscan
sele table_a
if !eof()
skip
scat memv
endif
enddo
close all

如果要使用 If..还。。。(只需在 Do while 循环中修改(

do while !eof()
sele table_b
go top
locate for firstname=m.firstname
if found()
wait wind allt(m.firstname)+" RecNo="+allt(str(recno()))
endif
sele table_a
if !eof()
skip
scat memv
endif
enddo

由于您在两个表中说了相同的数据,因此您需要将一个源记录中的每个字段与目标所有记录与其中的每个字段进行比较。
(假设两个表的数据结构在所有方面都相同(

CLOSE ALL  
CLEAR ALL  
RELEASE ALL  
SET TALK OFF  
SELECT 1
USE file1
GO TOP
SELECT 2
USE file2
DO WHILE NOT EOF()
SELECT 1
unq_found = 0
SELECT 2
GO TOP
DO WHILE NOT EOF()
SELECT 2
for ix = 1 to AFIELDS(TEST)
SRC_FLD = "A." + ALLTRIM(FIELD(IX))
TRG_FLD = "B." + ALLTRIM(FIELD(IX))
IF ALLTRIM(&SRC_FLD) <> ALLTRIM(&TRG_FLD)
unq_found = 1
EXIT for
ENDIF
ENDFOR
IF unq_found = 0
@00,00 CLEAR
@10,10 SAY "SAME DATA:- " 
@12,10 SAY "RECORD NUMBER:-" + STR ( RECNO() ) 
@18,10 SAY "PRESS A KEY TO CONTINUE"
READ
ENDIF
SKIP
ENDDO

SELECT 1
skip
ENDDO

最新更新