SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    USA
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Load Data Infile: Field List help

    ref: www.mysql.com/doc/en/LOAD_DATA.html
    The following example loads all columns of the persondata table:

    mysql> LOAD DATA INFILE 'persondata.txt' INTO TABLE persondata;

    No field list is specified, so LOAD DATA INFILE expects input rows to contain a field for each table column. The default FIELDS and LINES values are used.

    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.
    So..if TABLE persondata has field listing (person_fname,person_lname,person_phone,....) and the INFILE 'persondata.txt' has field listing (last name, first name, phone number, ...)...how would I map the INFILE fields into the TABLE fields (different names & column ordering)?

    Also if 'persondata.txt' has the column names in the first row, how can I use this to map my SQL statement?

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    USA
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *bump*

    don't tell me I stumped you all?


Bookmarks

Posting Permissions

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