On Wed, 28 Nov 2001, john wrote: > Yes, but won't this only replace and not load the rest of the items in > the file? > > This is my code, but it only updates the existing items. > > load data local infile '/tmp/Parts.txt' > >replace > >into table Parts > >fields optionally enclosed by '"' > >terminated by ',' > >('PN','APN','C','Q','D'); > > I have had that chunk of code working for a while, with the exception that > sometimes it only appends the items in the file and ignores the replace > switch? Wierd, huh?
John, The `REPLACE' and `IGNORE' keywords control handling of input records that duplicate existing records on unique key values. If you specify `REPLACE', new rows replace existing rows that have the same unique key value. If you specify `IGNORE', input rows that duplicate an existing row on a unique key value are skipped. If you don't specify either option, an error occurs when a duplicate key value is found, and the rest of the text file is ignored. (quoted from the manual) > The file has the twelve fields, five are listed above. I need to add a > stipulation to make the CUST_ID = 1. Would that be to add the following > line: > >set CUST_ID = '1' [placed before the replace switch] > > Is it the IGNORE switch that adds the rest of the items? > When using the IGNORE switch, should I use the "|" between REPLACE | IGNORE > as you have done? No '|' means OR, use one switch or the other. If you want to alter data contents while loading it might be better to LOAD into a fresh table and then INSERT ... SELECT from this table. Regards, Thomas --------------------------------------------------------------------- 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