Reputation: 173
I am trying to load a few thousand records into my MySQL db from a tab delimited text file, but I am getting the error message:
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' ENCLOSED BY '" '
LINES TERMINATED BY '\n'' at line 2
My command is:
LOAD DATA INFILE 'records.txt' INTO TABLE records (vendor, title, id, part, project,
description, machine, shelf, compartment, checkout)
FIELDS TERMINATED BY '\t' ENCLOSED BY '"'
LINES TERMINATED BY '\n';
I have tried different options such as OPTIONALLY ENCLOSED BY '"', LINES TERMINATED BY '\r\n', and adding a space after the quotation mark in ENCLOSED BY '" ', but I still get the error message above.
Where am I going wrong?
Upvotes: 1
Views: 1270
Reputation: 787
I am not very used to this command but I would say that the right query is :
LOAD DATA INFILE 'records.txt' INTO TABLE records
FIELDS TERMINATED BY '\t' ENCLOSED BY '"'
LINES TERMINATED BY '\n' (vendor, title, id, part, project,
description, machine, shelf, compartment, checkout);
Upvotes: 2