0

So I have this query:

SELECT * 
FROM `Nieuws`
INNER JOIN `Nieuws_tags` ON `Nieuws_tags`.`ID-Nieuws` = `Nieuws`.`ID` 
INNER JOIN `Tags` ON `Tags`.`ID` = `Nieuws_tags`.`ID-tags` 
WHERE Nieuws.ID = 1

Right now my output is:

enter image description here

What I need:

enter image description here

So I need one record where the "Beschrijving" (tag) stack up and not give me 2 records.

Someone told me about GROUP_CONCAT but I don't really know how to insert that if necessary.

1 Answers1

1

It is not 100% clear what is your DB schema, but just to show you the usage of GROUP_CONCAT function:

SELECT Nieuws.*,
       GROUP_CONCAT(Tags.Beschrijving)
FROM `Nieuws`
INNER JOIN `Nieuws_tags` 
ON `Nieuws_tags`.`ID-Nieuws` = `Nieuws`.`ID` 
INNER JOIN `Tags` 
ON `Tags`.`ID` = `Nieuws_tags`.`ID-tags` 
WHERE Nieuws.ID = 1
GROUP BY Nieuws.ID
Alex
  • 16,739
  • 1
  • 28
  • 51