I want to load the data from text file to database, if data already exists i need to escape that data while loading.
I am using below query to load the data from text file to mysql data base.
“Load data infile ‘F:/wbrdata.txt’ into table wbrdatatable
fields terminated by ‘,’
optionally enclosed by “”
lines terminated by ‘\r\n’
Ignore 1 lines (channel, time, pulserate, dwellid, targetid);”
It is appending the data to existing table data. I want to avoid the common data which is already exists(duplicates) in table & file while loading to the database.
How can i achieve this?
thank you
regards
sankar
Try to load text file into the temporary table (the same as target table), then remove duplicates from the temporary table and copy the rest to the target table.
Example (suppose that wbrdatatable_temp is a temporary table with all data from text file):