How can I accomplish on KNIME "INSERT ... ON DUPLICATE KEY UPDATE Statement"?

@bilgee I can demo the use with DB Merge in MySQL, with a workflow, if that helps

KNIME_db_ins_upd.knwf (36.8 KB)

In reality, of course, your data would be coming in from elsewhere, and we’d pass around credentials rather than coding 3 separate mysql connections but I’ve just put it into three individual workflows (1,2,3) so you can manually execute in sequence and look at the output from the DB Query Reader in each case. So you execute just workflow 1 followed by workflow 3, or you could execute 1 then 2 then 3. In both cases the result at 3 should be the same.

I don’t know why your merge would have taken a long time. Could there have been anything locking the table maybe in a separate session?

To test this workflow, obviously you’ll need to change the connection parameters to match your local db, but I think I’ve created the same student table albeit that here it is in my “gnl” schema that you’ll need to change to suit your setup.

2 Likes