喜欢在sqlite中查询

时间:2010-06-29 09:44:52

标签: iphone sqlite

NSString * strSearchSql = [NSString stringWithFormat:@"SELECT pdf_id,pdf_name,page_no,pdf_image,pdf_text FROM search WHERE pdf_text LIKE '\%%@\%'",strSearchString];

在这个查询中,我得到了类似的字符串 如下所示

SELECT pdf_id,pdf_name,page_no,pdf_image,pdf_text FROM search WHERE pdf_text LIKE '%@'

我想要这样

SELECT pdf_id,pdf_name,page_no,pdf_image,pdf_text FROM search WHERE pdf_text LIKE '%searchtext%'

请给我提示或提供一份文件。

1 个答案:

答案 0 :(得分:18)

转发查询中的%符号,例如%%而不是\%

NSString *strSearchSql = [NSString stringWithFormat:@"SELECT pdf_id,pdf_name,page_no,pdf_image,pdf_text FROM search WHERE pdf_text LIKE '%%%@%%'", strSearchString];