We have a table.
customer
+----+------+------+-------+
| id | type | name | group |
+----+------+------+-------+
| 1 | boy | dave | adult |
| 2 | girl | lisa | child |
| 3 | girl | amy | adult |
| 4 | boy | ivan | child |
+------------------+-------+
If we query this table with
SELECT * FROM `customer` WHERE type = 'girl'
Result output
Array
(
[0] => Array
(
[id] => 2
[type] => girl
[name] => lisa
[group] => child
)
[1] => Array
(
[id] => 3
[type] => girl
[name] => amy
[group] => adult
)
)
I would like to receive the output like the following.
Array
(
[girl] => Array
(
[child] => Array
(
[id] => 2
[name] => lisa
)
[adult] => Array
(
[id] => 3
[name] => amy
)
)
)
I could manipulate the result with another programming language, but wondered if this is possible with pure SQL?
Thanks in advance.