General information
Category:
Coding, syntax & commands
Title:
Using SQL to select unique records in 1 file from another
I've got a program that records all internet usage activity at our company. The program appends this information to a delimited text file. I have a VFP program that imports this into a table, that can be queried and reported on.
To acomplish this, currently I append all the information into a temporary file, then relate this temporary file to the original table, and delete all records that are already in the original like so :
use logfile in 0 shared order keyfield
copy structure to tempfile
use tempfile in 0 exclusive
select tempfile
append from (TextImportFile) type delimited
set relation to keyfield into logfile additive
delete all for not eof("logfile")
pack
select logfile
append from tempfile
use in tempfile
delete file tempfile.dbf
This works, but since the keyfield is actually a combination of several different typed fields, it requires a complex index and relation that is problematic. My question is this : Is there a way of using a select statement to select just the new items to be added.
I tried this :
select * from tempfile where tempfile.keyfield # logfile.keyfield
But this gives every combination between the two files that don't match. This is not what I want, I just want to know what records are in the tempfile that are not already in the logfile.
Anyone got any suggestions?
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only