select * fromtablewhere number like '%/%%' escape '/'... sqlite3數(shù)據(jù)庫在搜索的時候,一些特殊的字符需要進(jìn)行轉(zhuǎn)義, 具體的轉(zhuǎn)義如下:
/ -> //
' -> ''
[ -> /[
] -> /]
% -> /%
& -> /&
_ -> /_
( -> /(
) -> /)
需要注意的是,特殊字符并沒有用反斜杠“/”表示轉(zhuǎn)義符。
復(fù)制代碼代碼如下:
public static String sqliteEscape(String keyWord){
keyWord = keyWord.replace("/", "//");
keyWord = keyWord.replace("'", "''");
keyWord = keyWord.replace("[", "/[");
keyWord = keyWord.replace("]", "/]");
keyWord = keyWord.replace("%", "/%");
keyWord = keyWord.replace("&","/&");
keyWord = keyWord.replace("_", "/_");
keyWord = keyWord.replace("(", "/(");
keyWord = keyWord.replace(")", "/)");
return keyWord;
}