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