我有這個疑問:簡單的SQL問題(MySQL的)
SELECT page.id, revision.title, revision.number
FROM page
INNER JOIN revision ON page.id = revision.pageId
這將返回類似:
"1" "Page Version A" "1"
"1" "Page Version B" "2"
"1" "Page Version C" "3"
現在我只希望返回一行的每一頁,從數據最新版本(編號最高)的版本。如果我做的:
SELECT page.id, revision.title, revision.number
FROM page
INNER JOIN revision ON page.id = revision.pageId
GROUP BY page.id
我得到:
"1" "Page Version A" "1"
但我想:
"1" "Page Version C" "3"
任何想法? 謝謝。
輝煌,謝謝! :-) – 2009-02-03 10:36:19