Answer the question
In order to leave comments, you need to log in
How to replace duplicate value with null in sql select?
There are two tables between which a many-to-many relationship is established using a join table.
select f.name as filter_name,pg.name as group_name from filters as f join filters_products_group as fpg on f.id = fpg.filters_id join products_group as pg on fpg.products_group_id = pg.id
Answer the question
In order to leave comments, you need to log in
SELECT
CASE
WHEN (GROUP_CONCAT(f.name SEPARATOR '|||') LIKE '%|||%') THEN
NULL
ELSE
f.name
END AS filter_name,
pg.name AS group_name
FROM
filters AS f
JOIN filters_products_group AS fpg ON f.id = fpg.filters_id
JOIN products_group AS pg ON fpg.products_group_id = pg.id
GROUP BY f.name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question