Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PatrickBergman's avatar

SQL problem on three way pivot table

Hi all,

For some time I am in a struggle to find a solution to the given situation and problem:

These are my relations/tables: editions 1 ---- 0...* schedules volunteers 1 ---- 0...* schedules locations 1 ---- 0...* schedules team 1 ---- 0...* locations

Now I want to achieve the following result (in JSON format for understanding): editions: [ { id: # name: 'SomeString', locations: [ id: #, name: 'Otherstring', team: { id: # name: 'AnotherString' }, volunteers: [ { id: # name: 'John Doe' } ] ] } ]

I only want the volunteers for that specific location for that specific edition. Is this possible with larval relations? Or do I need to write it in pure SQL? And do any of you have a solution for me?

0 likes
0 replies

Please or to participate in this conversation.