# Control The Number of Rows Returned By A Query
__*LIMIT clause*__
```8
tidb> SELECT name FROM planets ~!@LIMIT@!~ 8;
+---------+
| name    |
+---------+
| Earth   |
| Jupiter |
| Mars    |
| Mercury |
| Neptune |
| Pluto   |
| Saturn  |
| Uranus  |
+---------+

tidb> SELECT name FROM planets ~!@ORDER BY@!~ distance_from_sun
   -> ~!@LIMIT@!~ 8;
+---------+
| name    |
+---------+
| Mercury |
| Venus   |
| Earth   |
| Mars    |
| Jupiter |
| Saturn  |
| Uranus  |
| Neptune |
+---------+
```

------------------------------------------------------------
Examine the results above and try to spot the differences.
- ORDER BY
  - The orderBy clause specifies the sort order of the results, which can be sorted by column, expression, or field somewhere in the select_expr list.
- LIMIT
  - The Limit clause is used to limit the number of results. Limit accepts one or two numeric arguments. If there is only one argument, it indicates the maximum number of rows to return. If it is two parameters, the first argument indicates the offset of the first row of return data (the offset of the first row of data is 0), and the second parameter specifies the maximum number of entries in the return data. The FETCH FIRST/NEXT n ROW/ROWS ONLY syntax is also supported, which has the same effect as LIMIT n, where n can be omitted and has the same effect as LIMIT 1 when omitted.

```
tidb> SELECT name FROM planets LIMIT 8;
+---------+
| name    |
+---------+
| Earth   |
| Jupiter |
| Mars    |
| Mercury |
| Neptune |
| Pluto   |
| Saturn  |
| Uranus  |
+---------+
8 rows in set (0.00 sec)

tidb> SELECT name FROM planets
   -> ORDER BY distance_from_sun
   -> LIMIT 8;
+---------+
| name    |
+---------+
| Mercury |
| Venus   |
| Earth   |
| Mars    |
| Jupiter |
| Saturn  |
| Uranus  |
| Neptune |
+---------+
8 rows in set (0.00 sec)
```


