I have the same request executed multiple times with different ID:
SELECT n.id
FROM news n
JOIN news_tag nt ON r.id=nt.id_news
WHERE nt.id_tag in (Select t.id_tag from news_tag t where t.id_news=2869)
ORDER BY r.id DESC
LIMIT 2
This request select the 2 last news that are with the same tags than the given news.
I would like to know how to perform the same request but to get the results for severals IDs in only one request!
This is a typical “Top N per group” query, with “B” being 2 in your case.
Here’s a generic solution I wrote for N records per group.