Xcode 如何在sqlite中为iphone应用编写like查询

Xcode 如何在sqlite中为iphone应用编写like查询,xcode,sqlite,Xcode,Sqlite,我对在iphone的示例应用程序中编写类似查询感到有点困惑。我像下面这样编写查询,但这没有帮助。我不知道我在这个查询中错在哪里 我传递的str_Id在这里是july,因为在db中我没有保存整个单词july,所以我需要与查询中的前3个单词进行比较(因此我不能使用select*from tbl,其中month=jul,所以我使用“like”查询) 希望我的问题清楚。我想你应该看看,还有试试%@而不是%@ const char *sql = [[NSString stringWithFormat:@"

我对在iphone的示例应用程序中编写类似查询感到有点困惑。我像下面这样编写查询,但这没有帮助。我不知道我在这个查询中错在哪里

我传递的str_Id在这里是july,因为在db中我没有保存整个单词july,所以我需要与查询中的前3个单词进行比较(因此我不能使用select*from tbl,其中month=jul,所以我使用“like”查询)


希望我的问题清楚。

我想你应该看看,还有

试试
%@
而不是
%@

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];

我使用的不是核心数据sqlite@abhi我在使用sqlite时使用了
NSPredicate
,但是可能有更好的方法。你能告诉我如何使用我上面的代码吗?这将非常有帮助。
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];