1. Salaryman
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    St. Louis, MO
    Rep Power

    Question LOAD DATA into table, ignoring some columns?

    I am using LOAD DATA to import a .csv file into a MySQL table, but have one problem. The .csv file has 14 columns of information, but I have no need for two columns so I designed the table with just 12 columns. I wan't to load in this .csv file excluding those two columns, is that possible?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Rep Power
    (excerpt from page 466 of the MySQL Manual)
    If you wish to load only some of a table's columns, specify a field list:

    mysql> LOAD DATA INFILE 'persondata.txt'
    -> INTO TABLE persondata (col1,col2,...);

    You must also specify a field list if the order of the fields in the input file differs from the order of the columns in the table. Otherwise, MySQL cannot tell how to match up input fields with table columns.

IMN logo majestic logo threadwatch logo seochat tools logo