I want to know the alternative of the TOP keyword as in MySQL. I have read about TOP in SQL Server.
Is there any alternative to this in MySQL, or any other method in MySQL from which we can get same fun开发者_JS百科ctionality?
Ordering and limiting the results:
SELECT field1, field2
FROM myTable
ORDER BY field1 ASC
LIMIT 10
You can use the LIMIT
keyword (See the documentation of the SELECT
instruction) -- it goes at the end of the query :
select *
from your_table
where ...
limit 10
to get the top 10 lines
Or even :
select *
from your_table
where ...
limit 5, 10
To get 10 lines, startig from the 6th (i.e. getting lines 6 to 15).
yes, there is the limit clause.
Example:
SELECT * FROM `your_table` LIMIT 0, 10
This will display the first 10 results from the database.
mysql equivalent of top and you can find further more about LIMIT in MySql Doc
精彩评论