I have a problem loading data into specific columns of an table. The CSV file is build dynamic with the default fields ID, LAST_REFRESH, ALIAS1 and may contain ALIAS2 to ALIAS8. Current CSV only contains ALIAS1-4
The MySQL table contains the columns ID, LAST_REFRESH, ALIAS1-ALIAS8. My code for the first file already fails. Code after variables are set is:
LOAD DATA LOCAL INFILE 'C:\\temp\\\OSS001'
INTO TABLE REJECTS (ID, REFRESH_DATE, ALIAS1, ALIAS2, ALIAS3, ALIAS4)
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
But unfortunately i still receive the following error:
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 ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
Anybody knows what i'm doing wrong?
Remove the columns:
The column names have to be specified last. Read more about it here.