MySQL Conditional Insert

前端 未结 13 1157
予麋鹿
予麋鹿 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:40

    You can use the following solution to solve your problem:

    INSERT INTO x_table(instance, user, item) 
        SELECT 919191, 123, 456
            FROM dual
            WHERE 123 NOT IN (SELECT user FROM x_table)
    
    0 讨论(0)
提交回复
热议问题