如何在iOS中获取/删除SQLITE表中的多行?

如何在iOS中获取/删除SQLITE表中的多行?,ios,objective-c,xcode,sqlite,Ios,Objective C,Xcode,Sqlite,我在SQLITE中的表格格式如下 id name date height 1 tt 12-2-15 120 2 ss 15-3-15 110 3 tt 14-5-15 120 .... 10 tt 19-6-15 130 (1) 我喜欢在一条指令中获得tt下的所有行,然后放入二维数组。我如何实现它 (2) 如何在一条指令中删除名称tt下的所有行 我的代码是iO

我在SQLITE中的表格格式如下

id   name      date      height
 1    tt     12-2-15       120
 2    ss     15-3-15       110
 3    tt     14-5-15       120
 ....
 10   tt     19-6-15       130
(1) 我喜欢在一条指令中获得tt下的所有行,然后放入二维数组。我如何实现它

(2) 如何在一条指令中删除名称tt下的所有行

我的代码是iOS。我不容易找到解决办法

编辑: 只是为了分享我实现的东西

    NSString *databasePath;
    NSString *docsDir;
    NSArray *dirPaths;

    //Database
    dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    docsDir = [dirPaths objectAtIndex:0];
    // Build the path to the database file
    databasePath = [[NSString alloc]initWithString:[docsDir stringByAppendingPathComponent: @"RECORDS.db"]];
    const char *dbpath = [databasePath UTF8String];
    if (sqlite3_open(dbpath,& RECORDS) == SQLITE_OK)
    {
        retval = [[NSMutableArray alloc] init];

        NSString *query = [NSString stringWithFormat:@"SELECT id, nameid, date, height FROM RECORD WHERE nameid=\"%@\"", currentNameID];
        const char *query_stmt = [query UTF8String];
        if (sqlite3_prepare_v2(RECORDS, query_stmt, -1, &statement, nil) == SQLITE_OK) {
            while (sqlite3_step(statement) == SQLITE_ROW) {
                char *date = (char *) sqlite3_column_text(statement, 1);
                int height = (int) sqlite3_column_text(statement, 2);
                NSString *name = [[NSString alloc] initWithUTF8String:date];
                HeightInfo *info = [[HeightInfo alloc] initWithInfos:name withheight:(int)height];
                [retval addObject:info];

            }
            sqlite3_finalize(statement);
            sqlite3_close(RECORDS);
        }
    }

谢谢

您需要SQL或ios框架方面的帮助吗?
SQL非常简单

select id, name, date, height from mytablename where name = "tt";

delete from mytablename where name == "tt";         
在命令行上练习这些命令,以便了解它们是如何工作的

要处理数据,请看Ray Wenderlich的优秀示例


这里有许多主题涉及SQLite。如果他们都帮不了你,那还有什么能帮你呢?对不起,兄弟。我只是不容易找到信息。现在我明白了。谢谢。我按照你的建议实施了。我不容易找到这些信息。谢谢