I have a table looks like this.
create table test1 (
id1 varchar(10),
id2 varchar(10),
value1 varchar(10),
value2 varchar(10),
primary key (id1, id2)
);
which contains the data looks like this:
id1 id2 value1 value2
stan marsh 1 2
eric cartman 3 4
I have a local CSV file which contains the updated data (contains new and old) looks like this:
"stan", "marsh", "5", "6"
"kyle", "broflovski", "7", "8"
How to import the csv file an meanwhile, update on duplicate key.
Few Links that might be helpful
- Import and overwrite existing data in MySQL (Same question but it was not answered properly)
- Mysql Insert on duplicate