我選擇記錄並按日期和uid(這不是主鍵)對它們進行分組,並且我需要按日期對這些記錄進行分頁,我該怎麼辦?
例如:mysql:如何限制查詢?
uid date 1 2012-01-10 2 2012-01-10 3 2012-01-09 3 2012-01-09 3 2012-01-11
SQL:
SELECT date, uid
FROM users
GROUP by date,`uid`
結果:
uid date 1 2012-01-10 2 2012-01-10 3 2012-01-09 3 2012-01-11
因爲我需要頁面按日期的記錄,如果我使用SQL這樣的:
SELECT date, uid
FROM users
GROUP by date,`uid`
LIMIT 0,2
然後我只是得到這樣的記錄:
uid date 1 2012-01-10 2 2012-01-10
。我怎樣才能按日期分頁記錄。 結果我想在頁面大小爲2:
uid date 1 2012-01-10 2 2012-01-10 3 2012-01-09
'LIMIT 0,3' ...... –