我有一個線程表和一個評論表。一個線程可以有很多意見 當我做mysql查詢。由於許多評論它變成重複的線程。 如何分組tid?PHP循環foreach重複
我試過在PHP的foreach,但仍然不知道。
Array
(
[0] => Array
(
[tid] => 110
[title] => This is question
[vid] => 175
[yesno] => 1
)
[1] => Array
(
[tid] => 110
[title] => This is question
[vid] => 179
[yesno] => 0
)
)
其實我是想這
Array
(
[0] => Array
(
[tid] => 110
[title] => This is question
[0] => Array(
[vid] => 175
[yesno] => 1
)
[1] => Array(
[vid] => 176
[yesno] => 0
)
)
)
使用'選擇不同thread.tid,thread.title,... ' –
'GROUP BY'在你的MySQL查詢中。 – BenM
'group by thread.tid'也可以工作 –