I am trying to load data into MYSQL (in MAMP) using LOAD DATA LOCAL INFILE. Some of the data elements specified in the database table are different from the column names in the data files (multiple csv files). For ex: the database has a column 'location_affected' and the data file has a column name 'location_name' for the same data element. Also, the data files not not have the same number of columns nor the same column names all through. Each data file might have around 30-40 columns out of the ~200 data elements specified in the database table. Could anyone suggest how to map the column names between the db table and the csv file? I tried the following but it throws an error: "location_name does not exist"
LOAD DATA LOCAL INFILE 'pathtothefile' INTO TABLE tablename
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r'
IGNORE 1 LINES
(col1,col2,col3..............)
SET location_name = location_affected ;