3

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();

2 Answers 2

2

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'.

Sign up to request clarification or add additional context in comments.

Comments

0

try putting auto out of ''

LINES TERMINATED BY auto

or use

LINES TERMINATED BY '\r\n'

1 Comment

Are you sure LINES TERMINATED BY auto does work?! It generates error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.