mysql - INSERT ON DUPLICATE KEY UPDATE with WHERE clause -
i'm creating record in mysql , if it's there don't want create it. update field called invite_state, mean whatever relation was, should go state invited. problem there 1 exception rule - if state unsubscribed shouldn't go invited.
so on duplicate key update in mysql doesn't support where clause. there workaround?
a workaround use if statement.
insert (...) values (...) on duplicate key update set invite_state = if(where_condition, new_value, invite_state)
Comments
Post a Comment