I am running with one LIKE
statement problem. The situation is that:
I'm saving phone number and name associated with that number from the contact book to app's db.
Then I am displaying this name in the uitableview by firing this query ...
NSString *sqlTemp =[NSString stringWithFormat:@"select name from phoneData where number like %'%@'%",number1];
number1
is (NSString *)
, the number I'm using is formatted like this (+international country code number)
. However number saved in db might be without country code and not prefixed with " +
" symbol.
So my question is that even if number saved in the contacts book is not according to the international phone number, how can I ensure that it matches the other digits in the number?
Can any one suggest me some solution to this?
Here is what you can do:
NSRange range = NSMakeRange (3, [number1 length] - 3);
NSString *noPrefixNumber = [number1 substringWithRange:range];
NSString *sqlTemp =[NSString stringWithFormat:@"select name from phoneData where number like %'%@'%",noPrefixNumber ];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.