Split joined result set to rows
<p>Have a stored procedure which process records from certain tables. To store some result generated by join operation there is a temporary table. </p>

<p>Table A</p>

<pre><code>+----+------+--------+
| id | name | number |
+----+------+--------+
|  1 | John |    123 |
|  2 | Tim  |    567 |
|  3 | Bill |    789 |
|  4 | Jim  |    345 |
+----+------+--------+
</code></pre>

<p>Table B</p>

<pre><code>+----+------+--------+
| id | code | number |
+----+------+--------+
|  1 | LK   |    123 |
|  2 | CN   |    123 |
|  3 | BN   |    789 |
|  4 | IN   |    345 |
+----+------+--------+
</code></pre>

<p>Table Temp</p>

<pre><code>+----+------+-----+------+--------+
| id | name | age | code | number |
+----+------+-----+------+--------+
|  1 | John |  54 | LK   |    123 |
|  1 | John |  54 | CK   |    123 |
|  3 | Bill |  26 | BN   |    789 |
|  4 | Jim  |  78 | IN   |    345 |
+----+------+-----+------+--------+
</code></pre>

<p>Converted the table Temp result set to JSON.</p>

<pre><code>[{"id":1,"name":"John","code":"LK","number":123}, {"id":2,"name":"John","code":"CK","number":123}, {"id":3,"name":"Bill","code":"BN","number":789}, {"id":4,"name":"Jim","code":"IN","number":345}]
</code></pre>

<p>I need to split the records to show it on view as below.</p>

<pre><code>+------------+-----+------+--------+
|    name    | age | code | number |
+------------+-----+------+--------+
| John       | 54  |      |        |
|            |     | LK   |    123 |
|            |     | CK   |    123 |
| Bill       |  26 |      |        |
|            |     | BN   |    789 |
| Jim        |  78 |      |        |
|            |     | IN   |    345 |
+------------+-----+------+--------+


[{"name":"John","age":54}, {"code":"LK","number":123}, {"code":"CK","number":123}, {"name":"Bill","age":26}, {"code":"BN","number":789}, {"name":"Jim","age":78}, {"code":"IN","number":345}]
</code></pre>

<p>What is an effective way, split the JSON or is it possible to generate such result set by querying table Temp in MySQL?</p>