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
Thanks a lot for the tiny flag advised by PM 77-1.
load data local infile '/Users/myuserID/Desktop/test1.csv'
replace
into table test.test1
columns terminated by ','
enclosed by '"'
lines terminated by '\n';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With