Using limit/offset

Limiting a result in SQL is a somewhat sad story. To make it short, every database does things somewhat differently. Although there is actually a SQL standard on limiting results, not everybody fully supports the way things are supposed to be. The correct way to limit data is to actually use the following syntax:

test=# SELECT * FROM t_test FETCH FIRST 3 ROWS ONLY;   id  ----    1    2    3 (3 rows)

If you have never seen this syntax before, don't worry. You are definitely not alone.

Get Mastering PostgreSQL 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.