如何以asc顺序从sql表中获取最后10条记录

时间:2009-11-19 19:21:38

标签: sql-server-2005

select top(10) from customer order by customer_id desc

4 个答案:

答案 0 :(得分:9)

select * 
from (select top 10 * from customer order by customer_id desc) a
order by  customer_id

答案 1 :(得分:2)

这在MS SQL中工作得很好但是对于MySQL我们必须要去 SELECT * FROM customer ORDER BY customer_id DESC LIMIT 10

答案 2 :(得分:1)

您似乎错过了要从表中检索的列列表。

考虑:

select top(10) 
*
from customer order by customer_id desc

select top(10) 
customer_id, customer_name
from customer order by customer_id desc

答案 3 :(得分:-1)

你可以使用:     SELECT * FROM customer ORDER BY customer_id DESC LIMIT 10