简体   繁体   中英

android SQLite : how to search string in like if string contains ' symbol

following is my query that I am trying to search name contain special character eg ' symbol

 SELECT * from  distributor where name like'%jeni's%'

when I tried to add backslash if work in MySQL but wont work in SQLite database I also tried following query

SELECT * from distributor where name like'%jeni\\'s%' can someone help me to how can i search if string contains ' symbol

Please try:

SELECT * from  distributor where name like'%jeni''s%'

Working solution:

Escape single quotes in statement like this:

String statement = statement.replace("'", "''")

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