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 ....
精彩评论