vendredi 3 avril 2015

How to pass multiple values of type NSString together for a query?

I have a table (named, tblUsers) with 5 rows like below,



-----------------------------------
(string) (string) (number)
-----------------------------------
ID NAME Age
-----------------------------------
abc H1 20
bca H2 30
dca H3 30
qwe H4 35
poi H5 25
-----------------------------------

Now I want to delete the rows having this IDs bca, dca, poi.


I know I can able to do it by using IN logical operator for SQLite.


And the query may be like this,


DELETE FROM tblUsers WHERE ID IN ('bca', 'dca', 'poi');


How can I programmatically append ' ' for each of the IDs?


Those IDs I've in an array, so I can use componentsJoinedByString: method of NSArray to join them, but I will also need to add it inside single quotes like this -> 'value'.


Aucun commentaire:

Enregistrer un commentaire