Answer the question
In order to leave comments, you need to log in
How to choose articles with tags?
table1 - table with articles
table2 - article-tag relationship table (2 columns id_art - article id, id_tag - tag id)
table3
-
table with tags tags and for each tag also a name from table3? It didn’t even work out for me to pull up the id, I tried this:SELECT * FROM `table1` LIMIT 10
SELECT * FROM `table1` LIMIT 6 LEFT JOIN `table2` WHERE `table1`.`id` = `table2`.`art_id`
Answer the question
In order to leave comments, you need to log in
like this
SELECT
arts.id_art,
COALESCE(GROUP_CONCAT(tags.name SEPARATOR ','), '')
FROM table1 arts
LEFT JOIN table2 _t ON _t.id_art = arts.id_art
LEFT JOIN table3 tags ON tags.id_tag = _t.id_tag
GROUP BY arts.id_art
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question