Reputation: 471
Running the following 2 queries (in postgres) returns the same results, but I see everywhere that method 1 is always preferred.
Are there any difference between the two queries? (Other than syntactic differences).
1)
SELECT * FROM table_name
OFFSET 5 ROWS
FETCH FIRST 5 ROWS ONLY;
2)
SELECT * FROM table_name
FETCH FIRST 5 ROWS ONLY
OFFSET 5 ROWS;
Upvotes: 1
Views: 295
Reputation: 311073
In PostgreSQL, there is no difference between the two statements. The SQL:2008 standard, however, places the offset
clause before the fetch
clause, so that would be the preferred form, in order to make your code as portable as possible.
Upvotes: 2