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

Hemang

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'.

Adeel Ahmad

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]

編集
0

コメントを追加

0

関連記事

分類Dev

How to lookup multiple items add their corresponding values together and generate a percentage

分類Dev

How to pass multiple button data to 1 query

分類Dev

How to query pass 2 of multiple conditions

分類Dev

django - how to pass multiple values to a templatetag

分類Dev

How to subclass an UIButton to pass multiple NSString parameters via addTarget:action:forControlEvents

分類Dev

How to insert multiple values in a single query

分類Dev

Pass multiple values to stored procedure

分類Dev

How to return multiple values from stored procedure within tsql query

分類Dev

How to implement "order by" together with "group by" in query

分類Dev

How to bind multiple elements to scroll together?

分類Dev

Firestore query for loop with multiple values

分類Dev

Type hinting values that are multiple types?

分類Dev

SQL query to check multiple values of multiple columns

分類Dev

How to pass input field values as a url query string that will be opened on click of a submit button?

分類Dev

Convert NSDictionary values to NSString

分類Dev

How to pass pageable for native query?

分類Dev

How to pass parameter on jpa query?

分類Dev

How to pass & symbol in MySQL query?

分類Dev

How to pass option values to a button

分類Dev

How does Deferred pass values?

分類Dev

Pass NSString between two DetailViewController

分類Dev

How to pass a Type into ConverterParameter in UWP?

分類Dev

How to return multiple values

分類Dev

ansible : how to pass multiple commands

分類Dev

How to bind two ng-models values together

分類Dev

How to bind two ng-models values together

分類Dev

Query to generate string based on values in multiple columns

分類Dev

Elasticsearch query to get values of multiple attributes

分類Dev

Returning null values with multiple table in a query

Related 関連記事

  1. 1

    How to lookup multiple items add their corresponding values together and generate a percentage

  2. 2

    How to pass multiple button data to 1 query

  3. 3

    How to query pass 2 of multiple conditions

  4. 4

    django - how to pass multiple values to a templatetag

  5. 5

    How to subclass an UIButton to pass multiple NSString parameters via addTarget:action:forControlEvents

  6. 6

    How to insert multiple values in a single query

  7. 7

    Pass multiple values to stored procedure

  8. 8

    How to return multiple values from stored procedure within tsql query

  9. 9

    How to implement "order by" together with "group by" in query

  10. 10

    How to bind multiple elements to scroll together?

  11. 11

    Firestore query for loop with multiple values

  12. 12

    Type hinting values that are multiple types?

  13. 13

    SQL query to check multiple values of multiple columns

  14. 14

    How to pass input field values as a url query string that will be opened on click of a submit button?

  15. 15

    Convert NSDictionary values to NSString

  16. 16

    How to pass pageable for native query?

  17. 17

    How to pass parameter on jpa query?

  18. 18

    How to pass & symbol in MySQL query?

  19. 19

    How to pass option values to a button

  20. 20

    How does Deferred pass values?

  21. 21

    Pass NSString between two DetailViewController

  22. 22

    How to pass a Type into ConverterParameter in UWP?

  23. 23

    How to return multiple values

  24. 24

    ansible : how to pass multiple commands

  25. 25

    How to bind two ng-models values together

  26. 26

    How to bind two ng-models values together

  27. 27

    Query to generate string based on values in multiple columns

  28. 28

    Elasticsearch query to get values of multiple attributes

  29. 29

    Returning null values with multiple table in a query

ホットタグ

アーカイブ