Answer the question
In order to leave comments, you need to log in
SQL: change duplicates. how to do?
Is it possible to implement the following without resorting to php. there is a url table, the keyword field contains the product alias, some may be the same, how to make a request to change the alias for duplicates, for example, add a random number
Answer the question
In order to leave comments, you need to log in
SET @r=0;
select id,tname,CONCAT (taliase , addid) as aliase from
(
select * from (
SELECT id,tname,taliase,@r:[email protected]+1 as addid
FROM FF as f1
GROUP BY f1.tname,f1.taliase
UNION
SELECT id,tname,taliase,"" as addid FROM FF as f2
GROUP BY f2.taliase
ORDER BY taliase DESC
) as t1
order by t1.id,t1.addid
) as t2
group by t2.id
CREATE TABLE FF
(`id` int, `tname` varchar(20), `taliase` varchar(20))
;
INSERT INTO FF
(`id`, `tname`, `taliase`)
VALUES
(1, 'baranka', 'hleb'),
(2, 'bulka', 'hleb'),
(3, 'pirozhok', 'hleb'),
(4, 'konfeta','sladkoe'),
(5, 'karamel','sladkoe')
;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question