I have a table with 1 primary key and 2 indexes. I use the "on duplicate key" statement in my stored procedure to update the existing rows when needed. However, the issue is that the even on duplicate key is triggered regardless what key is going to be duplicated.
I'd like to understand how can I make the difference in my stored procedure to update only when the duplicate is due to the primary key.
Typically, error below on primary key, OK to update:
#1062 - Duplicate entry '4' for key 'pp_member.PRIMARY'
Error below on Index, no update, throw exception instead.
#1062 - Duplicate entry 'aaa@aaa.com' for key 'pp_member.member_email_UNIQUE'