I use the solution below at the moment, the result is what I expected now.
myIDArray = @[@1, @2, @3];
...
executeQuery:[NSString stringWithFormat:@""
"SELECT name"
" FROM TABLE_A"
" WHERE a_id IN ("
" SELECT b_id"
" FROM TABLE_B"
" )"
" AND a_id IN %@", myIDArray];
But I wonder is there any way to INTERSECT two id lists inner IN (?)? Like
executeQuery:[NSString stringWithFormat:@""
"SELECT name"
" FROM TABLE_A"
" WHERE a_id IN ("
" SELECT b_id"
" FROM TABLE_B"
" INTERSECT"
" %@"// how to put my id array here appropriately?
" )", myIDArray];
Of course, this does not work, will throw syntax error.
I've also tried to use -componentsJoinedByString: to convert the array to string, w/ or w/o () for the string. No luck.
Aucun commentaire:
Enregistrer un commentaire