我想要從表中發佈8條最高評級的帖子(posts.rates)和8條最多查看的(posts.views)對同一個查詢,所以我得到16結果。這兩個字段在同一張桌子上。 所以很晚,實際上不知道該怎麼做。提前致謝。通過在mysql中查詢的雙重排序
我wan't不這樣做下面一個查詢,得到16行:
SELECT id FROM posts
ORDER BY rates DESC
LIMIT 0,8;
SELECT id FROM posts
ORDER BY views DESC
LIMIT 0,8;
編輯:答:
SELECT id FROM (SELECT id FROM posts ORDER BY views DESC LIMIT 0,8) AS a
UNION ALL
SELECT id FROM (SELECT id FROM posts ORDER BY rates DESC LIMIT 0,8) AS b
whhhhat?張貼一些代碼或去睡覺 – 2013-04-28 02:10:51
是的,我應該在這裏的 – Fosfor 2013-04-28 02:14:37