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
You can also use INSERT IGNORE
which silently ignores the insert instead of updating or inserting a row when you have a unique index on (user, item).
The query will look like this:
INSERT IGNORE INTO x_table(instance, user, item) VALUES (919191, 123, 456)
You can add the unique index with CREATE UNIQUE INDEX user_item ON x_table (user, item)
.