今天在做一个应用,需要实现数据库的模糊查询功能,在这里记录一下
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM TEST WHERE app like '%@%%'",keyword];//模糊查询,查找TEST中 以keyword开头的内容
// NSString *sql = [NSString stringWithFormat:@"SELECT * FROM TEST WHERE app like '%%%@%%'",keyword];//模糊查询,查询TEST中包含keyword 的内容
NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
FMResultSet *rs = [fmdb executeQuery:sql];
while ([rs next])
{
NSString * test = [rs stringForColumn:@"app"];
NSLog(@"查询结果%@");
}