problem with 'load data infile', please help

Discussion in 'Databases' started by simkeechai, Mar 29, 2006.

  1. #1
    hi there,

    i am having problem loading data into my table.

    here's my table 'mailing_list':
    id int auto_increment primary key
    email varchar(50)
    email_source varchar(150)
    country_id int(3)

    sample data (seperated by tab):
    xxx1@hotmail.com www.domain1.com 1
    xxx2@gmail.com www.domain2.com 1
    xxx3@blah.com www.domain3.com 1
    xxx4@dude.com www.domain4.com 1
    xxx5@kkk.com www.domain4.com 1

    i would like to know the correct syntax to load this kind of data into mailing_list, fields email, email_source, and country only; and when i load these data, the id will increase automatically.

    i tried to use the following syntax in query browser, but i got an error saying that there's error near line three:-

    load data infile 'file location'
    into table mailing_list
    fields terminated by ''
    lines terminated by '';

    in addition, what if the data file is csv file, how do i load data into the table?

    i appreciate your help. thank you in advance!
     
    simkeechai, Mar 29, 2006 IP
  2. sacx13

    sacx13 Active Member

    Messages:
    438
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Syntax is corect, try to remove lines terminated by or to set it to '\r\n' or '\n' (if unix) if still not working post the error on forum !

    If is a csv file you need to change fields terminated by '' with ','

    Regards
    Adrian
     
    sacx13, Mar 29, 2006 IP