O
O
Optimus2017-02-11 22:44:06
MySQL
Optimus, 2017-02-11 22:44:06

How to get an article and all tags with one request?

There is a table of art articles, a table of tag tags and a table of relat which indicate which article which tags refer to.
With one request:

SELECT * FROM `art`
LEFT JOIN `relat`
ON `art`.`id` = `relat`.`tagid`
WHERE `art`.`id` IN (1,2,3,4)

But then only one tag is selected for each article, and all are needed. In addition, I probably need something like a multidimensional array to conveniently display tags for a specific article, how can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dart, 2017-02-11
Pyan @marrk2

`art`.`id` = `relat`.`tagid`
article id = tag id? There is no mistake right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question