【问题标题】:SQLite select x-th rowSQLite 选择第 x 行
【发布时间】:2011-06-22 13:23:34
【问题描述】:

假设我有这张表,其中我删除了 rowid=3 的行:

rowid | something
------+-----------
    1 | ...
    2 | ...
    4 | ...
    5 | ...

如何选择第三行(rowid=4的那一行)?

【问题讨论】:

    标签: sql sqlite select rowid


    【解决方案1】:

    select * from table limit 2,1

    意思是“从索引 2 开始并返回 1 行”。

    【讨论】:

      【解决方案2】:
      select * from yourtable order by rowid limit 1 offset 2;
      

      将为您提供该排序结果集中的第三行(偏移量从 0 开始)。

      【讨论】:

        【解决方案3】:

        选择 Max(row_id) from ( select * from table_name 限制 3)

        【讨论】:

          猜你喜欢
          • 2020-09-22
          • 1970-01-01
          • 1970-01-01
          • 2013-07-30
          • 1970-01-01
          • 2012-08-29
          • 1970-01-01
          • 2023-03-17
          • 2013-11-18
          相关资源
          最近更新 更多