My MySQL "data" EAV table has a genetic structure like that:
rowId  |  key |  value
  1       name    John
  1       lname   Lennon
  2       name    Paul
 ....
I like to do a select that will display the data in the table as if the keys were the column names:
rowId  | name |  lname
  1      John     Lennon
  2      Paul
  ....
Following some links like this one, I created this query:
SELECT st.rowId, st.key, st.value,
  (CASE WHEN data.key = "name" THEN data.value END) AS `name`, 
  (CASE WHEN data.key = "lname" THEN data.value END) AS `lname`
FROM data st 
GROUP BY st.rowId;
But I get the following error:
Unknown column 'data.key' in 'field list'
I tried to change the " sign as suggested here but no success yet.