sql - MYSQL - Combine rows with multiple duplicate values and delete duplicates afterwards -
so have database set single table. in table have collected source url , description (i scraping product description number of pages). unfortunately have ended multiple rows in database url/source page if there more 1 paragraph.
what is, if there multiple rows same url, combine description each row , delete duplicate rows url.
my table literally structured so:
table +----+----------------------------+-------------+ | id | url | description | +----+----------------------------+-------------+ | 1 | http://example.com/page-a | paragraph 1 | | 2 | http://example.com/page-a | paragraph 2 | | 3 | http://example.com/page-a | paragraph 3 | | 4 | http://example.com/page-b | paragraph 1 | | 5 | http://example.com/page-b | paragraph 2 | +----+----------------------------+-------------+ how want like:
table +----+----------------------------+-------------------------------------+ | id | url | description | +----+----------------------------+-------------------------------------+ | 1 | http://example.com/page-a | paragraph 1 paragraph 2 paragraph 3 | | 2 | http://example.com/page-b | paragraph 1 paragraph 2 | +----+----------------------------+-------------------------------------+ i'm not bothered ids being updated correct, want able combine rows paragraphs should in same field same urls, , delete duplicates.
any appreciated!
it's easy filter table, insert result in new table:
select url, group_concat(description order description separator ' ') description `table` group url
Comments
Post a Comment