开发者

How do i only pull the top "x" rows from a table?

I have this query

$query_return = database::query("SELECT * FROM tw ORDER BY time DESC");

that pulls all the rows, however I only want the开发者_如何转开发 top x=8 rows.

How do I modify it?

Thanks!


Use LIMIT:

SELECT * FROM tw ORDER BY time DESC LIMIT 8


Add a limit clause:

$query_return = database::query("SELECT * FROM tw ORDER BY time DESC LIMIT 8");


If code is for MS-SQL use TOP e.g. SELECT TOP (8) * FROM ....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜