▲>>1547935
Вот с форума нашёл:
INSERT INTO x_table(instance, user, item)
SELECT 919191, 123, 456
FROM dual
WHERE NOT EXISTS (SELECT * FROM x_table
WHERE user = 123
AND item = 456)
или
ALTER TABLE x_table ADD UNIQUE KEY `x_table_date` (`user`, `date`);
INSERT INTO x_table (`instance`, `user`, `item`)
VALUES (23, 123, 456)
ON DUPLICATE KEY UPDATE `instance` = `instance`; --this keeps the instance what it was (no change to the table) or:
INSERT INTO x_table (`instance`, `user`, `item`)
VALUES (23, 123, 456)
ON DUPLICATE KEY UPDATE `instance` = 23; --this updates the price to the new value