If I need select 20 to 30 rows from PostgreSQL, how can I retrieve that ?
SELECT column FROM table LIMIT 10
This is fetching top 10 rows only. Can we do this in PostgreSQL ?
If I need select 20 to 30 rows from PostgreSQL, how can I retrieve that ?
SELECT column FROM table LIMIT 10
This is fetching top 10 rows only. Can we do this in PostgreSQL ?
Specify OFFSET
in addition to LIMIT
:
SELECT column FROM table LIMIT 10 OFFSET 20
You may want to use the ORDER BY
clause as well as by default the rows are returned in an unspecified order.
See LIMIT and OFFSET in the PostgreSQL docs.
OFFSET actually just says how many rows to skip before beginning to return rows which in this case are limited to 10 rows. You just want to change the number of rows you are limiting to:
select column from table limit 20;
or
select column from table limit 30;