T
T
TurinTur2020-06-30 09:37:39
MySQL
TurinTur, 2020-06-30 09:37:39

There are duplicates when querying GROUP_CONCAT, how to get rid of them?

Here is the request itself, it works correctly

SELECT p.*, GROUP_CONCAT(s.sectionId) as "sections", GROUP_CONCAT(t.tagId) as "tags" FROM products AS p 
LEFT JOIN sections AS s ON p.id = s.productId 
LEFT JOIN tags AS t on p.id = t.productId 
GROUP BY p.id, p.name

But there are such duplicates
5efadd58a8cdd173861539.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-06-30
@TurinTur

GROUP_CONCAT(DISTINCT ...)
https://dev.mysql.com/doc/refman/8.0/en/aggregate-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question