In MariaDB how do I select the top 10 rows from a table?

mariadb, mysql, select, sql, top-n

Solution

You can use the `limit` clause:

SELECT * FROM route LIMIT 10

This can, of course, be used on a sorted query too:

SELECT * FROM route ORDER BY some_field LIMIT 10

Problem

I just read online that MariaDB (which SQLZoo uses), is based on MySQL. So I thought that I can use ROW_NUMBER() function However, when I try this function in SQLZoo : ``` SELECT * FROM ( SELECT * FROM route ) TEST7 WHERE ROW_NUMBER() < 10 ``` then I get this error : Error: FUNCTION gisq.ROW_NUMBER does not exist

Original source

Related problems