MySQL pivoting column names based on column values?

Viewed 27

I have a table of data like:

ID1   F1.   F2.   F3
X1. Enabled. Disabled. Disabled
X2. Disabled. Enabled. Enabled. 

I'd like to get it into the form of:

ID1  Fields
X1.  F1
X2.  F2,F3

But I'm having writers block on how to approach the problem. Is this something a pivot would help with? Self-joining the table? I've tried some group_concat() aggregations on if() statements to no avail, similarly with grouping on case whens.

1 Answers
Related