Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    5

    Unanswered: LOAD DATA INFILE from csv and specifying order

    Hello,

    I've been trying to load about 400,000 entries into mysql using LOAD DATA INFILE. I import it from a csv file, however when I try to specify the order of loading fields I always get a syntax error.

    This is the code that works:

    LOAD DATA CONCURRENT INFILE '/home/virtual/path/var/www/html/FILE' REPLACE
    INTO TABLE tbl_name FIELDS TERMINATED BY ',' ENCLOSED BY '"'
    LINES TERMINATED BY '\n';

    However when I type:

    LOAD DATA CONCURRENT INFILE '/home/virtual/path/var/www/html/FILE' REPLACE
    INTO TABLE tbl_name (col1,col2,col3,col4) FIELDS TERMINATED BY ',' ENCLOSED BY '"'
    LINES TERMINATED BY '\n';

    I always get an error syntax.

    Does anyone have a solution? I've searched the web for loading values from a csv file while specifying values load order and I couldn't find anything.

    Thanks a lot for your help,

    Narcís

  2. #2
    Join Date
    Nov 2003
    Posts
    91
    try moving (col1,col2,col3,col4) to the end of your LOAD DATA statement.
    When you get errors you should post them so we can see what the problem is.

  3. #3
    Join Date
    Oct 2003
    Posts
    5
    Thanks a lot! it worked! :-)

    Narcís

  4. #4
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    To learn more on Load Data you can check this

    http://www.lasso-developpeur.net/us/...tab=db&lang=us
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •