Skip to content
Advertisement

Mysql JSON_OBJECT aggregate json objects to json array where id matches

As mentioned in the title, i’ve been trying to aggregate json objects to a json array where the id is the same. I’ve got a main table “kurs” that has a unique id and is connected to the table “kompetenz” over a link table. For each “kurs” there can be multiple “kompetenzen”. However after a few hours of trying i still couldnt get it to work. enter image description here

this is the link table

This is my query:

the result im getting is following: enter image description here

but i want to aggregate all the json objects in the column “kurskompetenzen_erlerndend” to a json_array where the id at the front of the result set is the same. I don’t know what im missing, i’m not experienced with sql. Hope anyone can help, thanks in advance 🙂

Advertisement

Answer

Found the answer myself shortly after i thought i won’t be able to solve it.

Worked with this query:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement