Reputation:
I try to import a csv file into MySQL database. CSV file : have some email addresses separated with comma(file name is "email.csv") MySQL database : (database name is "test") have two column (id, email) id is INT, primary key and auto incremented, email is VARCHAR OS : Microsoft windows XP when I try to use the following command :
LOAD DATA LOCAL INFILE "C:\email.csv" INTO TABLE test.email FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' (id,email);
but only 1 row inserted (The result is shown below):
Query OK, 1 row affected, 1 warning (0.06 sec)
Records: 1 Deleted: 0 Skipped: 0 Warnings: 1
What should I do to
Upvotes: 1
Views: 5997
Reputation: 49049
If your csv file is like this:
[email protected],[email protected],[email protected],[email protected],e[email protected]
you could use this:
LOAD DATA LOCAL INFILE 'C:\email.csv' INTO TABLE prova.email
LINES TERMINATED BY ',' (email);
you need to read every email, and put it in a new row, so what you need is a LINES TERMINATED BY ','
, rows are then read this way:
[email protected]
[email protected]
[email protected]
[email protected]
e[email protected]
Upvotes: 1