如何在sql中返回10个最新结果?

时间:2021-10-13 09:08:17

This works fine and gives me the most recent results back:

这很好,并给我最新的结果:

SELECT * FROM table ORDER BY date ASC;

But when I put a limit on it to reduce the results to just 10 of the most recent, it doesn't give me the most recent results:

但是当我对它进行限制以将结果减少到最近的10时,它并没有给我最新的结果:

SELECT * FROM table ORDER BY date ASC LIMIT 30;

How else can I do this?

我怎么能这样做?

4 个解决方案

#1


1  

try

SELECT * FROM table ORDER BY date DESC LIMIT 10;

the DESC clause asks for records with the most recent date first. Assuming your date field is a DATETIME-style field, this should work.

DESC子句首先要求记录最近的日期。假设您的日期字段是DATETIME样式字段,这应该可行。

#2


1  

why don't you order by id (or date) DESC LIMIT 10

为什么不按ID(或日期)DESC LIMIT 10订购

#3


0  

Try the following:

请尝试以下方法:

SELECT Top(10) FROM table ORDER BY date ASC    

#4


0  

you can use

您可以使用

select top 30 * FROM table ORDER BY date ; 

#1


1  

try

SELECT * FROM table ORDER BY date DESC LIMIT 10;

the DESC clause asks for records with the most recent date first. Assuming your date field is a DATETIME-style field, this should work.

DESC子句首先要求记录最近的日期。假设您的日期字段是DATETIME样式字段,这应该可行。

#2


1  

why don't you order by id (or date) DESC LIMIT 10

为什么不按ID(或日期)DESC LIMIT 10订购

#3


0  

Try the following:

请尝试以下方法:

SELECT Top(10) FROM table ORDER BY date ASC    

#4


0  

you can use

您可以使用

select top 30 * FROM table ORDER BY date ;