9
我知道如何在mysql中创建数据透视表(请参阅下面的代码示例),但如果数据透视表中的列数非常大,而且我不想输入2000左右的标记名? - 有没有办法让这个列表生成? 非常感谢提前。mysql中的数据透视表
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;
外观在 本文。 http://buysql.com/mysql/14-how-to-automate-pivot-tables.html – GeoGo 2012-04-06 15:02:33