【问题标题】:How to fetch new Records each time with the increement of 10 using sqlite?如何使用sqlite每次以10的增量获取新记录?
【发布时间】:2014-02-20 10:04:39
【问题描述】:

我有一个包含图像名称和 URL 的表格。

[db executeQuery:"drop table ImagesTable;"];
        [db executeQuery:"create table ImagesTable ('no' INTEGER PRIMARY KEY AUTOINCREMENT, 'img_name' text, 'img_url' text);"];

现在我正在使用限制以这种方式获取记录

NSMutableArray *recordSet=[db getRecordSet:"select * from ImagesTable limit 0,10;"];

当上述 10 张图片下载后,我将删除上述 10 条记录,以便下次我再次获得 10 条这样的新记录

NSString *sqlQuery=[NSString stringWithFormat:@"delete from ImagesTable where no=%d;",[[[imgArr objectAtIndex:i] objectAtIndex:0] intValue]];
                    [db executeQuery:(char *)[sqlQuery cStringUsingEncoding:NSUTF8StringEncoding]];
                    [img release];
                     counter++;

现在我的问题是在不删除记录的情况下如何每次以 10 的增量获取新记录。如下所示 示例:- 0 到 10,10 到 20, 20 到 30 等等。提前致谢

【问题讨论】:

    标签: iphone sql sqlite select


    【解决方案1】:

    documentation 解释了 LIMIT 之后的第一个数字的用途。

    第一页使用LIMIT 0,10,第二页使用LIMIT 10,10,第三页使用LIMIT 20,10,以此类推

    【讨论】:

    • 感谢您的回复,但我在表中没有修复记录,它将是动态的,那么我该如何像这样写 LIMIT 0,10, 10,10, 20,10?
    猜你喜欢
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 2012-10-10
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多