Reputation: 523
I am running this MySQL command:
LOAD DATA LOCAL INFILE 'books.csv'
INTO TABLE BOOK (Book_id, @dummy, Title, Publisher_name, @dummy, @dummy)
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
I am getting an error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use near
'FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' IGNORE 1 LINES' at line 3
What am I doing wrong here?
Upvotes: 3
Views: 16464
Reputation: 153882
You have an error in your SQL syntax;
Take a deep breath, this error is infurating and why MySQL sucks. You have a lot of work work to do to figure out what you did wrong:
If you get this error it means the SQL parser encountered an error because of one of the following reasons:
!@#$%^&*()-_=+[]{}\|;:'",.<>/?
. select
, into
, or any of the thousands of others. Break the SQL down into smaller and smaller pieces until you are left with the minimum possible statement that fails.
The syntax error will leap out at you, you will slap your forehead, and be one step closer to uninstalling the MySQL badware and getting postgreSQL instead which does not subject the user to such infuriating general errors.
Upvotes: 5
Reputation: 562330
http://dev.mysql.com/doc/refman/5.6/en/load-data.html shows the syntax. The clause naming columns goes after the IGNORE clause.
LOAD DATA LOCAL INFILE 'books.csv'
INTO TABLE BOOK
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(Book_id, @dummy, Title, Publisher_name, @dummy, @dummy);
Upvotes: 11