mercredi 24 décembre 2014

Return multiple rows grouped by a column and named by other column value

Not sure if title is formulated correctly, so there is better explanation:


Table: users_data



uid | key | value
1 | "age" | "23"
1 | "city" | "London"
1 | "name" | "John"
2 | "age" | "19"
2 | "city" | "Tokio"
2 | "name" | "Aiko"


Query: Select data of users aged 23.


Result should look like this:



uid | age | city | name
1 | "23" | "London" | "John"


Don't even have current code since I have no idea if it is possible to name columns by value of field, sorry.


Aucun commentaire:

Enregistrer un commentaire