You will need to add a primary key to the column in your table that will uniquely identify a record. The IGNORE keyword only ignores records that would generate a "duplicate key" error if there is already a record in the table with the same key value. So, use ALTER TABLE and add a primary key to one of your columns. "---==[bolMyn]==---" wrote: > > Well, it seems like nobody wants to bite the question I posted a few > days ago about ignoring duplicate records during bulk import. So I > thought, that maybe answer was so obvious that I could not miss it. > > I found the following: > > "LOAD DATA [LOW_PRIORITY] [LOCAL] INFILE 'file_name.txt' [REPLACE | > IGNORE] > INTO TABLE tbl_name > [FIELDS > [TERMINATED BY '\t'] > [[OPTIONALLY] ENCLOSED BY ''] > [ESCAPED BY '\\' ] > ] > [LINES TERMINATED BY '\n'] > [IGNORE number LINES] > [(col_name,...)]" > > The part which I found confusing was: INFILE 'file_name.txt' [REPLACE | > IGNORE] because there was 'IGNORE' clause down below. There is no > better way to find out the results like testing. So, I exported first a > few thousands records from one of my tables and then, imported them back > using the above syntax. > > What I did was: > > LOAD DATA INFILE '/tmp/myfile.txt' INGORE INTO TABLE mytable > > If I understand this syntax correctly, MySQL was supposed to skip > duplicate records from my import file which were identical to the ones > in the table. Well, nothing like that happened. MySQL happily > 'imported' all the records, consequently accepting duplicates. My > question is: "What gives?" What is a correct syntax to avoid > duplicates? > > MySQL version I'm running is 3.22.32, running on Linux kernel 2.2.18 (RH > 6.2 distro). > > Sent via Deja.com > http://www.deja.com/ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php