问:@H_404_1@
@H_404_1@
I have simple question with sqlite. What is the difference between this:@H_404_1@
Select * from Animals LIMIT 100 OFFSET 50
and@H_404_1@
100,50
答:@H_404_1@
@H_404_1@
The two Syntax forms are a little confusing because they reverse the numbers:@H_404_1@
LIMIT <skip>,count>
Is equivalent to:@H_404_1@
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.@H_404_1@
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.@H_404_1@