Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
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?
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement