SQL: Limit and Order By

This entry is part 17 of 20 in the series SQL Tutorial

You can order the rows selected using order by clause, with the following syntax:

select ... from tableName where condition order by column asc|desc

SQL Fiddle

At times, you might only just want to return a certain number of rows.  This can be achieved by using Limit in MySQL.

select * from artiste limit 2

SQL Fiddle

For Sybase, it will be done by using Top instead of Limit.


Series Navigation<< SQL: Let there be select
SQL: NULL value >>

Leave a comment

Leave a Reply