简体   繁体   English

向用于从数据库中获取数据的 NSString 添加双引号

[英]Add double quotes to NSString that is used to fetch data from database

I have a string like this nsstring *mystring=@"vikas";我有一个像这样的字符串nsstring *mystring=@"vikas"; now i want to add this " so the new string would be "vikas"现在我想添加这个"所以新字符串将是"vikas"

any way to do this?有什么办法可以做到这一点?

I want to perform some query like :-我想执行一些查询,如:-

NSString *myQuery=[NSString stringWithFormat:
                  @"select * from questiontable where order = %d",ordernumber];

where i want to add double quotes on order like :- "order"我想在订单上添加双引号,例如:-“订单”

You should be writing query in NSString in format:您应该以 NSString 格式编写查询:

NSString *myQuery = [NSString stringWithFormat:
              @"select * from questiontable where \"order\" = %d",ordernumber];

It must work fine.它必须工作正常。

Trace!痕迹! You can follow the Pratyusha's approach.您可以遵循 Pratyusha 的方法。 And, also if you use single quote than also I think your query will be executed.而且,如果您使用单引号,我认为您的查询也会被执行。 Have you tried that means put your vikas in like that manner- 'vikas', or in the case of assigning the same to NSString like that:-你有没有试过这意味着把你的 vikas 放在这样的方式 - 'vikas',或者在像这样将相同的值分配给 NSString 的情况下:-

NSString *mySingleQuotedString = @"'vikas'";

I hope, it'll also worked.我希望,它也会奏效。 Please try it.请尝试一下。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM