Is there an alternative to TOP in MySQL?

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).

Tags:

Mysql

Sql