I have a table with the following columns:
ID | Name | Source
The ID is auto-increment and primary key. I need to load data from CSV file. The data in the file are in the following format: Name, Source.
I need to load data from the file without duplicate. I specified the field Name in my table to be unique and run the following statement:
LOAD DATA INFILE 'F:/myfile.csv'
IGNORE
INTO TABLE test(name,source)
COLUMNS TERMINATED BY ','
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n';
But I am getting error in the SQL syntax. Can you please help me.
I don’t think you can specify columns in your table statement:
Try it like this. Per http://dev.mysql.com/doc/refman/5.1/en/load-data.html