简体   繁体   中英

Like query in sqlite

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

In This Query i got the String like given below

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

I want like this

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

Please give me hint or provide me a document.

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

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM