Command to display a limit of records in a table

2
Assuming a database has a locacoes table, which SQL command would display between the tenth and twentieth registers of this table, sorted by field titulo ?

    
asked by anonymous 30.08.2014 / 02:27

1 answer

6
SELECT * FROM locacoes ORDER BY titulo LIMIT 9,10;

You do not have much information but that's probably it.

In this case you do not use WHERE because you do not need to filter anything. Use ORDER BY to set sort and LIMIT 9,10 to get the tenth result and the next 10. It uses the numeric 9 to indicate the initial element because it starts from 0, so if the first one is 0 the tenth is 9.

    
30.08.2014 / 02:45