Search code examples
phpmysqldatabasecsvload-data-infile

LOAD DATA IN FILE ERROR


SQL says Error in Line 7.

Problem in accepting the attributes of the CSV file. Thank you in advance for your suggestions and solutions!

LOAD DATA INFILE 'C:\Users\TO115956\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\databse\W2.csv'
INTO TABLE W2
FIELDS TERMINATED BY ';'
ENCLOSED BY '"' 
LINES TERMINATED BY '\n'
IGNORE 1 LINES 
(Cde Sap;Num cde cl;Type cde;Bloc livra;Bloc Fact;Org vente;Canal Dist;Sect Act;Don. Ordre;Motif cde;Prix HT;Devise;Terme;Statut_Cde;Date créat;Date creat;Date ACKN;Date PRES;Date RES;Date VAES;Date RFQ;Date VALI;Date REB;RQUO;Date livra;Date SM;Date factu;Avis;PN in;Code chain;Type fab;SN in;Doc Client;Garantie;Livraison;Poste liv;LTA2;VOL2;DATE2;Qté livrée;PN out;SN out;Facture;Montant;Devise)

MySQL said:

1064 - 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 'Sap' at line 7


Solution

  • Last line of your query should contain database column names. These names should not contain spaces, or dots. (I think they can not actually)

    So, you need to change those, to your real column names, not the header from CSV.

    Or if your column order matches, you can just remove the last line.