2016-12-17 82 views
0

傢伙我有表:: 1,2,3,4,5,6,7,8,9,10ORDER BY ID DESC LIMIT 3

查詢等DATAS:

SELECT done_sum FROM spent_vs_done WHERE project_id="14" ORDER BY id DESC LIMIT 3 

結果我現在看起來像這樣:

10,9,8 

我想獲得像最後3行:

8,9,10 

你能幫我添加一些東西到查詢中來實現嗎?

MySQL的/ PHP

任何幫助將不勝感激!!!!

+0

使用'ASC'相反DESC' –

回答

1

使用子查詢來獲取升序:

SELECT t.done_sum 
FROM 
(
    SELECT done_sum, id 
    FROM spent_vs_done 
    WHERE project_id="14" 
    ORDER BY id DESC 
    LIMIT 3 
) t 
ORDER BY t.id 
+0

作品奇妙的',非常感謝! –

+0

@JarekJarek標記正確嗎? –