Answer the question
In order to leave comments, you need to log in
How to use ON DUPLICATE KEY UPDATE?
Tell me how to rename the values when they match in the slug cell? Ideally, add a digit with a hyphen. If slug exists, then trace. will be slug-2 if there is such a slug-3, and so on.
what I sketched does not update - swears at a double
CREATE TABLE IF NOT EXISTS `table` (
`slug` varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `slug` (`slug`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `wc_terms` (`id`, `name`, `slug`) VALUES
(1, 'value', 'value'),
(2, 'value', 'value'),
(3, 'value', 'value')
ON DUPLICATE KEY UPDATE slug = slug + 1;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question