2016-07-03 53 views
0

我有一個表取表最新的條目。最後一行數據庫表

表A

id value 
__ _____ 
1  a 
2  b 
3  c 
4  d 
5  e 

我想獲取在表中只有最新的入門(IE)的最後一個值 => ID,價值爲5,E

你能否告訴我這個問題?

+2

的[在MySQL中選擇最後一排]可能的複製(http://stackoverflow.com/questions/ 4073923 /選擇,最後一排,在MySQL的) –

回答

1

使用下面的select查詢

SELECT * FROM tablea where ID IN (SELECT MAX(ID) FROM tablea); 
1

使用order bylimit

select t.* 
from t 
order by id desc 
limit 1; 
1
Select id, value 
    from tablea 
order by id desc 
limit 1 
相關問題