我想使用 SQLite3 在 iOS XCode 中进行选择,如下所示:
//arraycat is the array from which the data comes...multiple selections of a tableview
pros = [arraycat componentsJoinedByString:@","];
const char *sqlselect = "SELECT DISTINCT zuser.zid, zuser.zplz,zuser.zort,zuser.zhofname,zuser.zstrassenr,zuser.zlatitude,zuser.zlongitude FROM zuser,zangebot,zkategorie WHERE zkategorie.zprodukt IN(?) and zangebot.zprodukte=1 and zkategorie.zuser_id=zuser.zid and zangebot.zuser_id=zuser.zid and zkategorie.zdelete_r=0 and zangebot.zdelete_r=0";
if (sqlite3_prepare_v2(database, sqlselect, -1, &selectStmt, NULL) != SQLITE_OK) {
NSAssert1(0,@"Failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
NSLog(@"abfrage select produkt hat nicht geklappt");
}
//here has to be the problem...
sqlite3_bind_text(selectStmt, 1, [pros UTF8String], -1, SQLITE_STATIC);
如果我只在 tableview 上选择一个类别,那么它可以工作,但如果我选择多个并将它们发送到这个语句,那么它就不起作用。为什么这个?IN(?)
当我在 SQL Query中手动编写类别时,('Vegetable','fruits')
它也可以工作......为什么不使用该componentsJoinedByString
方法?