I know how to make a pivot table in mysql (see code example below), but what if the number of columns in the pivot table is very large and I don't want to type 2000 or so tagnames? - Is there a way to have that list generated? Many thanks in advance.
drop table pivot;
create table pivot SELECT time,
max(if(tagname = 'a', value, null)) AS 'a',
max(if(tagname = 'b', value, null)) AS 'b',
max(if(tagname = 'c', value, null)) AS 'c'
FROM test where tagname in ('a','b','c')
GROUP BY time;
select * from pivot;