Find out a set of results for sqlite, and then continue to check this group of results by for cycle. Is there an easy way?

find out a set of results for sqlite, then run a for loop on this group of results and continue to check the database with sqlite to get similar results. Here is the method I am currently using. Is there an easy way?

sources of topics and their own ideas

related codes

  • (void) AccordingtoWithBlockReult: (void (^) (NSArray *) BlockResultArray

Radicl: (NSString *) radicl {

NSString * Sql = [NSString stringWithFormat:@"SELECT GROUP_CONCAT(DISTINCT b)FROM tableA WHERE R = "%@ "",r];
NSArray * array1 = nil;
FMResultSet * set =   [self.db executeQuery:Sql];
while ([set next]) {
    array1  = [[set stringForColumn:@"GROUP_CONCAT(DISTINCT b)"] componentsSeparatedByString:@","];
    array1 = [array1 sortedArrayUsingComparator:[self sort]];
}
NSMutableArray * tmpArray = [[NSMutableArray alloc]init];

[array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
    NSString * Sql2 = [NSString stringWithFormat:@"SELECT GROUP_CONCAT(DISTINCT name)FROM tableA WHERE  R = "%@ " and b = "%@"",radicl,obj];
    [self.dbQueue inDatabase:^(FMDatabase *db) {
        NSArray * array2 = nil;
        CollectionCategoryModel * model= nil;
        FMResultSet * set =   [db executeQuery:BuShouSql2];
        while ([set next]) {
            array2  = [[set stringForColumn:@"GROUP_CONCAT(DISTINCT name)"] componentsSeparatedByString:@","];
            model = [CollectionCategoryModel itemWithDataArray:[[NSMutableArray alloc]initWithArray:array2] sectionTitle:[NSString stringWithFormat:@"%@",obj]];
        }
        [tmpArray addObject:model];
    }];
}];
BlockResultArray(tmpArray);

}

[self.dbQueue inDatabase: ^ (FMDatabase * db)}];

can you use this method to merge sql1 and slq2 and find out array1 and array2 at the same time? thank you

Jun.09,2022
Menu