Option 1: Query Distinct Values and Construct Dynamic SQL
Query for distinct values in the dimension you want to pivot (e.g., "way").Create an array of SQL fragments representing the maximum对于每个不同维度值的时间。
使用逗号将SQL片段连接到单个查询字符串中。; $ way_array [] =“ max(if(`way` = $ way,`time'))为way_ $ way'; } $ pivotsql =“ select stop”。加入(“,”,$ Way_array)。 “从`fore of'of`of ot ot ot of ot ot of ot o of ot o of ot o';
选项2:查询和后传播数据行,rowexample:; 如果(!array_key_exists($ stopkey,$ stoparray)){ $ stoparray [$ stopkey] = array(“ stop” => $ stopkey); } $ waykey =“ way_”。 $ row [“ Way”]; $ stoparray [$ stopkey] [$ waykey] = $ row [“ time”]; }
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3