Hi-- I'm having a persistent problems with a mysql LOAD DATA INFILE job I'm running. I have three or four csv files I need to import into a db, they all fail with the same error. I've googled all over and tried a bunch of things to fix it, but can't figure out why this is popping up. Thanks in advance for any help! (Note: using the exact same files and options worked fine with a mysqlimport, but it fails using load data infile which I thought was basically identical!)
here's the statement:
LOAD DATA LOCAL INFILE '/scripts/myfile.txt' INTO TABLE table (id,title) FIELDS TERMINATED BY ',' ENCLOSED BY '"'
Here's a sample of the actual txt file:
The database table is simply two columns: id varchar(5) and title varchar (255)
I've tried the statement both with and without the LOCAL modifier, it seems to make no difference. The error I get is
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 ',' ENCLOSED BY '"'' at line 1
As far as I can tell from reading the manual and about a dozen examples is that my syntax is correct. Any ideas?
SOLVED: for anyone finding this, there's quite a few incomplete or erroneous examples on the net. Here's the right syntax: LOAD DATA LOCAL INFILE '/scripts/myfile.txt' INTO TABLE table FIELDS TERMINATED BY ',' ENCLOSED BY '"' (id,title)