I am facing a problem inserting data from a CSV file into MySQL.
I have different types of CSV files, each with different columns. But, all files contain some common columns. I need to read only selected columns from the file.
Example CSV Columns
File 1: "Name","Mobile","Gender","Address","City","State"
File 2: "Name","Mobile","Distict","Operator","Address"
File 3: "Name","Mobile","Address"
My MySQL table structure is like this:
name | mobile | address
I am using the following method:
LOAD DATA INFILE '/path/to/file' INTO TABLE example FIELDS TERMINATED BY ','
ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (col1, col2, col3, ...);
I got few errors and I am unable to load data in accurately. Thanks in advance.