Hi all,
This great forum has provided me with most of my questions; I wish all sites had such great search functionalities. I couldn't however find an answer to this question though: How to pivot the profile_values tables?
Short version: How to pivot the profile_values table so that it's laid out horizontally like this: [ uid | value1 | value2 | ... | valueX ] instead of vertically as it is now?
Long version: I have to build up a table containg information about a user, and only one record should be used pr. user. I need the values in the profile_values table as part of this as it contains demographic information. Therefore I believe I need to pivot the table and have settled for an approach I've used before: "put null in a value field unless it equals an indexing number and finally group by id" (which might not be a good way of doing it, and I welcome suggestions of doing it another way). However, when I put this SQL into a .inc file it just doesn't work and the MySQL error message is of little help saying "refer to the manual". So I was wondering if anyone have already done this (pivoting the profile_values table that is) and would like to share the SQL? This is the SQL statement I think would work:
SELECT uid, group_concat(if(fid = 1, value, null)) AS Birthday,
group_concat(if(fid = 2, value, null)) AS Gender,