Search code examples
mysqlsqldatabaseload-data-infile

MySQL ERROR 1064 cause (LOAD DATA INFILE)


When I run this SQL commands within MySQL

LOAD DATA INFILE 'myFile.csv' INTO myTable FIELDS TERMINATED BY ','

I get this error:

ERROR 1064 (42000) at line 1: 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 'TO myTable FIELDS TERMINATED BY ','' at line 1

This message isn't very helpful, it can appear for one of countless syntax errors.

How do I find out what mistake I've made with such a generalized "it won't work" error message?


Solution

  • try

    LOAD DATA INFILE 'myFile.csv' INTO TABLE myTable 
    FIELDS TERMINATED BY ','
    

    (chage TO to INTO TABLE)

    Taken from the documentation