I have a few column with UNIQUE INDEX
. In some queries, duplicates should be acceptable, in which a postfix should be added to the value. For example, if test title
exits, we change it to test title-2
.
Is there a way to make a unique value upon DUPLICATE
?
INSERT INTO table1
(title, abr, name)
VALUES
('title', 'abr', 'name')
In this typical example, all three columns are UNIQUE
. When the INSERT
fails, I do not know which col caused the error to change its corresponding value.
How can I make a query to change value
to value-identifier
upon duplicate error?