0

Compiler says the syntax error is near "FIELDS TERMINATED....."

LOAD DATA LOCAL INFILE '/Data/books.csv' 
INTO TABLE Book 
IGNORE 1 LINES
(@col1,@col2,@dummy,@dummy,@dummy,@dummy,@dummy,@dummy) 
set Book_id=@col1,Title=@col2
FIELDS TERMINATED BY '\t' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n' 
2
  • 2
    post a sample of you books.csv Commented Oct 2, 2015 at 3:24
  • Thank you, while David has solved the problem ; ) Commented Oct 3, 2015 at 21:41

1 Answer 1

3

That is because you have the column list and set before your fields clause. Mysql will have used the defaults when no fields|lines was encountered then processed the col list and then thrown an error when it encountered the fields clause. Try this

LOAD DATA LOCAL INFILE '/Data/books.csv' 
INTO TABLE Book 
FIELDS TERMINATED BY '\t' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n' 
IGNORE 1 LINES
(@col1,@col2,@dummy,@dummy,@dummy,@dummy,@dummy,@dummy) 
set Book_id=@col1,Title=@col2
Sign up to request clarification or add additional context in comments.

Comments

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.