加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Sqlite LIMIT / OFFSET的疑问

发布时间:2020-12-12 20:40:06 所属栏目:百科 来源:网络整理
导读:问: 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 e

问:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读