0

I'm learning database. I came across LIMIT keyword and its usage. In some tutorial it was specified as

LIMIT row_number OFFSET n will select row_number of rows after skipping n rows

And in another tutorial it was written as

LIMIT offset, row_number will select row_number of rows after skipping offset rows

Now which syntax is correct, if both are correct then where to use what?

trim24
  • 249
  • 3
  • 12

2 Answers2

3

LIMIT row_number OFFSET n syntax is for MySQL, PostgreSQL and SQLite

LIMIT offset, row_number is for MySQL

Microsoft SQL Server uses a completely different approach: https://stackoverflow.com/a/10440718/234661

Oracle is similarly difficult: https://stackoverflow.com/a/26051830/234661

Firebird has several methods. The recommended one in Firebird 2.5 and earlier is ROWS m TO n, and Firebird 3.0 introduced SQL Standard OFFSET/FETCH.

They are different because they haven't been standardized before being implemented.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Alex
  • 14,338
  • 5
  • 41
  • 59
0

Both are same as they are generating same results.

The difference is only when you use second one LIMIT offset, row_number There is only syntax difference

You can use any of them based on your requirements

M.suleman Khan
  • 576
  • 6
  • 17