如何在sqlite中编写像查询一样的iphone应用程序

时间:2011-06-30 16:28:47

标签: xcode sqlite

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

我正在传递的str_Id在7月份就像在db中说的那样我没有保存整个单词7月所以我需要比较查询中的前3个单词(所以我不能使用select * from tbl where month = jul,所以我使用“喜欢”查询)

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

希望我对我的问题很清楚。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

尝试%%@而不是%@

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