4
我試圖修改此查詢:雙組查詢?
SELECT (WEEKDAY(date) +1) dayofweek, COUNT(*) count
FROM abanners
WHERE iid = ? AND banner LIKE ?
GROUP BY (WEEKDAY(date) +1)
ORDER BY count DESC
與此查詢我得到星期splited條目數,但如果我要得到同樣的事情由banner
也分裂了什麼?
所以我想有:
banner1: entries splitted by day of week
banner2: entries splitted by day of week
ex: {"banner1" : "1,3,4,1,3,5,1", "banner2": "1,3,4,1,3,5,1"}
我該怎麼辦?
只需將「橫幅」添加到「SELECT」列表和「GROUP BY」。 –
這樣就給了我:'array('dayofweek'=>'1','COUNT(*)'=>'4','count'=>'banner1')' – PurpleFoxy
'banner'必須在「GROUP BY」的週日。 (同樣,你可以在GROUP BY中使用別名'dayofweek') - 你不需要MySQL中的完整表達式,就像使用SQL Server一樣,例如 –