How to write like query in sqlite ,for iphone app
I am bit confused about writing like query in a sample app for iphone .I am writing query like this as below but this does not help.I dont know where i am wrong in this query.
The str_Id i am passing is say july here as in db i am not saving the whole word july so i need to compare like the first 3 words in the query(So i cant use select * from tbl where month = jul ,so i use the "like" query )
const char *sql = [[NSString stringWithFormat:@开发者_JAVA百科"select TourID, Tourname, Firstname, Lastname, Notes, Date, isSale, Image, SolidAmount, SolidDate, isPaid from SalesDataentry where Month like %@",str_Id]UTF8String];
Hope i am clear with my question.
I think you should check out the NSPredicate
Documentation, and also the Introduction to Predicates Programming Guide
try %%@
instead of %@
const char *sql = [[NSString stringWithFormat:@"select TourID, Tourname, Firstname, Lastname, Notes, Date, isSale, Image, SolidAmount, SolidDate, isPaid from SalesDataentry where Month like %%@",str_Id]UTF8String];
精彩评论