I would like to print a list of items from a database table, and together with each one, a little list (10 items max) of related subitems.
For example, I have these 2 tables:
ITEMS
id: integer
name: string
SUBITEMS
id: integer
name: string
item_id: integer
So, an item can have many subitems.
I would like to print something like this:
Item 1
this item has: subitem 1, subitem 2, subitem 3
Item 2
this item has: subitem 4, subitem 5, subitem 6
Item 3
this item has: subitem 2, subitem 4, subitem 7
How can this be done in SQL? Is this even possible?
If it’s MySQL then