我有以下查詢:顯示下面的查詢用逗號分隔的列表
SELECT coalesce(COUNT('view_id'),0) level1count,y,m
from
(select 1 as m,2016 as y
union
select 2 as m,2016 as y
union
select 3 as m,2016 as y
union
select 4 as m,2016 as y
union
select 5 as m,2016 as y
union
select 6 as m,2016 as y
union
select 7 as m,2016 as y
union
select 8 as m,2016 as y
union
select 9 as m,2016 as y
union
select 10 as m,2016 as y
union
select 11 as m,2016 as y
union
select 12 as m ,2016 as y
) months
left join page_views on(months.m = month(page_views.view_date) and months.y = year(page_views.view_date))
group by months.m, year(page_views.view_date)
導致以下:
level1count Year Month
-----------------------------------------
1 2016 1
1 2016 2
1 2016 3
1 2016 4
34 2016 5
1392 2016 6
49 2016 7
1095 2016 8
1173 2016 9
859 2016 10
605 2016 11
100 2016 12
我需要得到level1count顯示如下:
1,1,1,1,34,1392,49,1095,1173,859,605,100
使用PHP - 我剛剛開始使用PHP和開發在其中放置一個網站。我在想,也許它需要放入一個數組,然後以某種方式迴應?
對不起,如果這是一個愚蠢的問題,但正如我所說 - PHP非常新,並慢慢掌握它。
非常感謝
JS
到目前爲止的任何PHP代碼?基本上將所有'level1count'值移動到數組中'$ array [] = $ row ['level1count']'然後執行'implode(',',$ array);'。那將會完成這項工作。 – JustOnUnderMillions
顯示用於處理該查詢結果集的代碼**編輯您的問題**不要在評論中粘貼 – RiggsFolly