Tom,

   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?

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?

thanks for your confirmation.



-----Original Message-----
From: Thomas Spahni [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 28, 2001 2:40 AM
To: john
Cc: MySQL Lists
Subject: RE: Beginner - Updating a Table from a File


On Tue, 27 Nov 2001, john wrote:

>    I want to be able to do an update from a text file I have placed in the
> /tmp dir. I have searched the "Manual" and it does not state how to do
this.

John,

It took me not too long to find in the very fine Manual:

-------quote ---------

`LOAD DATA INFILE' Syntax
=========================

     LOAD DATA [LOW_PRIORITY | CONCURRENT] [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 `LOAD DATA INFILE' statement reads rows from a text file into a
table at a very high speed.  If the `LOCAL' keyword is specified, the
file is read from the client host.  If `LOCAL' is not specified, the
file must be located on the server.  (`LOCAL' is available in *MySQL*
Version 3.22.6 or later.)
( ...)
----- unquote ----------

Is it that what you are looking for?

Cheers,
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


---------------------------------------------------------------------
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

Reply via email to