Forum Moderators: open
You may be using a database which lets you access rows in a table by a squence number but if you are asking generically about SQL it makes no sense. Rows have keys, positions are an implemenation issue which, in a properly designed dbms, is totally transparrent to queries.
Although I might agree in theory I would disagree in practice. Have you ever written a pagination function for a database that does not offer some form of offset and/or limit clause? Consider the following:
SELECT LastName, FirstName, MiddleName, IdentificationNumber FROM myTable ORDER BY LastName, FirstName, MiddleName, IdentificationNumber;
Now you want to display only the first 10 rows. OK, so you fetch only the first ten rows and free your result set. Display your data and wait for user input. Now your user wants to page forward. How do you handle it? With a logical WHERE clause, correct?
SELECT
LastName,
FirstName,
MiddleName,
IdentificationNumber
FROM myTable
WHERE
(
LastName > 'Last-LastNameDisplayed'
OR
(
LastName = 'Last-LastNameDisplayed'
AND
(
FirstName > 'Last-FirstNameDisplayed'
OR
(
FirstName = 'Last-FirstNameDisplayed'
AND
(
MiddleName > 'Last-MiddleNameDisplayed'
OR
(
MiddleName = 'Last-MiddleNameDisplayed'
AND
IdentificationNumber > 123456
)
)
)
)
)
)
;
The ability to use an offset and a limit definitely has it's advantages.
One secret to effective SQL programming (and programming in general I think) is write CLEAN code.