2012-07-16 120 views

回答

1

假設soru_id決定表

的開始/結束試試這個:

SELECT DISTINCT soru_id 
    FROM <YOUR_TABLE> 
ORDER BY date_created DESC 
LIMIT 10; 

如果你獨自一人需要整行,而不是soru_id的。然後試試這個:

SELECT * 
FROM <YOUR_TABLE> a 
JOIN 
    (SELECT soru_id, 
      MAX(date_created) date_created 
    FROM <YOUR_TABLE> 
    GROUP BY soru_id LIMIT 10) b ON a.soru_id = b.soru_id 
AND a.creation_date = b.creation_date 
+0

顯然'soru_id'不能確定從示例中可以看出的順序,否則第一行將包含在結果中。我猜測它是名爲'crea ...'的列,可能決定訂單......'creation_date'? – 2012-07-16 22:47:23

+0

@MarkByers看起來像這樣。此外,絕對意識到,OP正在尋找整行......將更新答案 – Chandu 2012-07-16 22:48:44