问:
I have simple question with sqlite. What is the difference between this:
Select * from Animals LIMIT 100 OFFSET 50
and
100,50
答:
The two Syntax forms are a little confusing because they reverse the numbers:
LIMIT <skip>,count>
Is equivalent to:
OFFSET
It's compatible with the Syntax from MysqL and Postgresql. MysqL supports both Syntax forms,and itsdocsclaim that the second Syntax with OFFSET was meant to provide compatibility with Postgresql. Postgresqldocsshow it only supports the second Syntax.
By the way,using LIMIT without first using ORDER BY may not always give you the results you intend. In practice,sqlite will return the rows in some order,probably determined by how they're physically stored in the file. But this doesn't necessarily mean it's in the order you want. The only way to get a predictable order is to use ORDER BY explicitly.
原文链接:https://www.f2er.com/sqlite/202440.html