Skip to content

LIMIT Clause

Use the LIMIT clause to limit the number of rows that a query returns.

[ LIMIT { count | ALL } ]

LIMIT ALL means return all rows. LIMIT 0 means return no rows. Use an ORDER BY clause if you want a query to consistently return the same subset of rows.

For example:

premdb=# select * from match order by matchday limit 0;
 seasonid | matchday | htid | atid | ftscore | htscore 
----------+----------+------+------+---------+---------
(0 rows)
premdb=# select * from match order by matchday limit 3;
 seasonid |      matchday       | htid | atid | ftscore | htscore 
----------+---------------------+------+------+---------+---------
       1 | 1992-08-01 00:00:00 |    2 |   52 | 0-1     | -  
       1 | 1992-08-01 00:00:00 |    2 |   55 | 0-1     | -  
       1 | 1992-08-01 00:00:00 |    2 |   63 | 2-1     | -  
(3 rows)

Parent topic:SELECT