Ios 如何将select语句与objc中的多个where值一起使用?
我认为这不是正确的格式,因为控制台在nslog处停止检索所有权结果。我需要解决这个问题吗?创建临时表以存储qr的where,然后搜索where用户?或者我可以只更新我的sql语句吗Ios 如何将select语句与objc中的多个where值一起使用?,ios,sql,objective-c,fmdb,Ios,Sql,Objective C,Fmdb,我认为这不是正确的格式,因为控制台在nslog处停止检索所有权结果。我需要解决这个问题吗?创建临时表以存储qr的where,然后搜索where用户?或者我可以只更新我的sql语句吗 [database executeQuery:@"select * from ownership where qrcode = ? and user = ?;", ktQRcode, userktid]; NSLog(@"retrieving ownership results through qrcode and
[database executeQuery:@"select * from ownership where qrcode = ? and user = ?;", ktQRcode, userktid];
NSLog(@"retrieving ownership results through qrcode and userid");
while ([results next]) {
OWNERSHIP *ktownership = [OWNERSHIP new];
ktownership.uniqueIDownership = [results intForColumn:@"id"];
ktownership.user = [results intForColumn:@"user"];
ktownership.qrcode = [results intForColumn:@"qrcode"];
ktownership.create_at = [results dateForColumn:@"create_at"];
[foundOwnership addObject:ktownership];
ownershipcount = [foundOwnership count];
NSLog(@"addnewownership count: %lu", foundOwnership.count);
NSLog(@"addnewownership Array: %@", foundOwnership);
您没有向我们显示分配
结果的位置
变量。您还应检查故障,例如:
FMResultSet *results = [database executeQuery:@"select * from ownership where qrcode = ? and user = ?;", ktQRcode, userktid];
if (!results) {
NSLog(@"select error: %@", [database lastErrorMessage]);
} else {
NSLog(@"retrieving ownership results through qrcode and userid");
}
while ([results next]) {
OWNERSHIP *ktownership = [OWNERSHIP new];
// the rest of your code here
}
“它停止”是什么意思?您是否收到错误消息或堆栈跟踪?你有没有不小心在那一行设置了一个断点(空白处的蓝色标志)?好的,我就这么做了,但是我没有收到错误消息,所以我现在做的是只选择where qrcode=?然后我只在ktownership.user==useridI的情况下将结果添加到我的数组。我不明白这个问题:你是说当你将
user
条件添加到where
子句时,你没有得到任何记录,但是如果你从SQL中省略它,你会得到很多记录,包括你最初寻找的记录?您绝对不应该检索所有内容,然后手动对其进行筛选。听起来似乎存在一些简单的数据问题,但根据提供的有限信息,根本不清楚问题是什么。