Drahcir
Drahcir

Reputation: 11972

MySQL Error message with LOAD DATA LOCAL INFILE

My error message 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 'auto'' at line 5

My query is:

LOAD DATA LOCAL INFILE 'D:\file.csv'
INTO TABLE `tableName`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\'
LINES TERMINATED BY 'auto'

I'm running the query via php function mysql_query();

Upvotes: 3

Views: 1654

Answers (2)

Michael Berkowski
Michael Berkowski

Reputation: 270609

The problem here is that the query sees an unclosed single quote after defining the escape sequence.

 ESCAPED BY '\' <-- unclosed quote!

By default, MySQL uses a backslash as the escape character. If you wish to be explicit, I believe you will need to use a double-backslash:

 ESCAPED BY '\\'

Then, remove the quotes around 'auto'.

Upvotes: 2

LostMohican
LostMohican

Reputation: 3144

try putting auto out of ''

LINES TERMINATED BY auto

or use

LINES TERMINATED BY '\r\n'

Upvotes: 0

Related Questions