I have 2 tables one (Teams) with basic team information and other (Teammeta) with all additional information structured as keys and values. I want a query where teams.id
matched with teammeta.team_id
and output result in the form of keys and values given in desired result.
TABLE: Teams
| id | Name | |----|------------| | 1 | Glagiators | | 2 | Sultans |
TABLE: Teammeta
| tmeta_id | team_id | meta_key | meta_value | |----------|---------|----------|------------| | 1 | 1 | player1 | Joe | | 2 | 1 | player2 | Mark | | 3 | 2 | player1 | Smith | | 4 | 2 | player2 | Drake |
TABLE: Desired Result
Array ( [0] => stdClass Object ( [Name] => Glagiators [player1] => Joe [player2] => Mark ) [1] => stdClass Object ( [Name] => Sultans [player1] => Smith [player2] => Drake ) )