Hello,
My database is organized in two tables, called content and additional_info. The structure is as followed:
content
ID | title | text
----------------------
1 | Title A | Text A
2 | Title B | Text B
additional_info
ID | idContent | info
-----------------------
1 | 1 | Info A1
1 | 1 | Info A2
1 | 2 | Info B1
1 | 2 | Info B2
Now I like to show my users a HTML table such as
Result (desired):
Title | Information
---------------------------
Title A | Info A1, Info A2
Title B | Info B1, Info B2
Selecting the data with a JOIN_
SELECT
c.title,
i.info
FROM
Content c
JOIN
additional_info a ON a.idContent = c.ID
returns a table with four rows:
Title | Information
----------------------
Title A | Info A1
Title A | Info A2
Title B | Info B1
Title B | Info B2
My current solution is to check the value of the title. If there is no chance, I add the information, if there is a change, I print the new title in a new row (<tr>). But maybe there is also a more dynamic way or a solution “imploding” the information….?
Thank you,
Simon