MySQL Conditional Insert

前端 未结 13 1142
予麋鹿
予麋鹿 2020-11-22 09:51

I am having a difficult time forming a conditional INSERT

I have x_table with columns (instance, user, item) where instance ID is unique. I want to insert a new row

13条回答
  •  名媛妹妹
    2020-11-22 10:17

    Slight modification to Alex's response, you could also just reference the existing column value:

    Insert into x_table (instance, user, item) values (919191, 123, 456) 
      ON DUPLICATE KEY UPDATE user=user
    

提交回复
热议问题