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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -