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'.
How can I programmatically append ' ' for each of the IDs?
NSMutableArray *arr = [YourArray mutableCopy];
for(int i = 0 ; i<arr.count ; i++)
[arr replaceObjectAtIndex:i withObject:[[NSString alloc ] initWithFormat:@"'%@'", [arr objectAtIndex:i ]]];
Then use componentsJoinedByString:
method of NSMutableArray
to join
Note: Its not tested. Im writing to give you a starting point.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加