I'm trying to do an update in MySQL using a local CSV file, am convinced that my syntax should be right, but am obviously missing something since MySQL tells me:
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 '"' ( ArtikelNummer, Tags ) LINES TERMINA' at line 3
The code I use is the following:
CREATE TEMPORARY TABLE TempTable LIKE Assortiment;
LOAD DATA LOCAL INFILE 'C:\\Users\\Website\\website data\\stock.csv'
INTO TABLE TempTable ( ArtikelNo, Tags )
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';
UPDATE assortiment
INNER JOIN TempTable
ON TempTable.ArtikelNo = assortiment.ArtikelNo
SET assortiment.Tags = TempTable.Tags;
DROP TEMPORARY TABLE TempTable;
The target table uses a lot of columns, the csv file only 2
I'm think the error is in the column specification ( ArtikelNo, Tags ), because when I leave that away there is no syntax error anymore (only a wrong mapping). I tried putting this at different locations, made sure the column names are correct, but that didn't help.
Obviously a work around would be to make sure the columns of the CSV are in the right order and put in some dummy columns where needed, but I want to find out why this goes wrong.
I'm using MySQL query browser, version 5.1.11, Using server version 5.5.20.