不同的價值觀我有5場數據庫:組數據基於字段並提取PHP
1. id
2. text (just a phrase in each row)
3. opinion (holds values: positive or negative or neutral)
4. location (where the person who wrote the text was)
5. label (specific to the text)
我想要做的就是使用PHP & MySQL的獲取特定標籤的位置和能夠顯示出這個位置有多少積極消極中立的意見。
結果應該最終是這樣的:
Amsterdam - 2 positive, 3 negative, 5 neutral
.... - #.., #.., #..
and so on..
我要繪製的條形圖這些數據,這就是爲什麼我需要它。我想過使用GROUP BY,但出於某種原因,我無法得到我想要的結果。
我該怎麼做?
編輯: 樣品上 sqlfiddle
期望的結果:
Location | Positive | Negative | Neutral
city1 2 1 2
city2 2 1 0
使用此查詢,它看起來像我到達那裏,但結果顯示,一切都是中性的。例如,一個地點有31箇中立,6個積極,1個否定,並且只有38箇中立。 這是爲什麼? – Andrew
然後這個問題必須缺乏一些信息。請提供樣本數據和期望的結果,最好在http://sqlfiddle.com上哦,並且'show create table your_table_name_here'的結果,可以肯定。 – fancyPants
編輯我的第一篇文章,添加sqlfiddle樣本數據。 – Andrew