MySQL restructuring data for a VIEW
Some code that I am reworking has a table that looks like this:
--------------------------- | uid | key | val | --------------------------- | 1 | name | Aaron | | 1 | age | 28 | | 1 | iq | 50 | | 2 | name | John | | 2 | age | 17 | | 2 | iq | 110 | | 2 | geekfu | 100 | ---------------------------
And I want to create a view that looks like this:
--------------------------------------- | uid | name | age | iq | geekfu | --------------------------------------- | 1 | Aaron | 28 | 50 | null | | 2 | John | 17 | 110| 100 | ---------------------------------------
The PHP code I’m looking at is running through loops to organize the code, I am thinking there must be a simpler way. Any pointers to put start me in the right direction?