Answer the question
In order to leave comments, you need to log in
How to make an increment when two fields are unique?
There is a table categories (shop_id, index, title)
And there is an index on shop_id and index so that they do not repeat (so that the store does not have the same indexes)
So, I try this query:
update `categories` set `index` = `index` + 1 where `shop_id` = '23eb94c0-1a19-11e8-acea-ade469f32ac7'
#1062 - Дублирующаяся запись '1-23eb94c0-1a19-11e8-acea-ade469f32ac7' по ключу 'categories_index_shop_id_unique'
update `categories` set `index` = `index` - 1 where `shop_id` = '23eb94c0-1a19-11e8-acea-ade469f32ac7'
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