Web DB - SQLite LIKE语法...逃避我

时间:2012-01-31 03:39:00

标签: sqlite webdb

尝试这些:

tx.executeSql(“SELECT * FROM Animal_Traits WHERE animalName LIKE%?%或trait LIKE%?%ORDER BY animalName”,[searchValue,searchValue],

有了这个,我被告知语法在%符号上中断...所以如果我试试这个:

tx.executeSql(“SELECT * FROM Animal_Traits WHERE animalName LIKE'%'?'%'或trait LIKE'%'?'%'ORDER BY animalName”,[searchValue,searchValue],

它告诉我语法中断?符号...(猜猜第一个?)如果我尝试这个:

tx.executeSql(“SELECT * FROM Animal_Traits WHERE animalName LIKE'%?%'或trait LIKE'%?%'ORDER BY animalName”,[searchValue,searchValue],

它告诉我参数的数量不匹配... grrr!

请有人帮助我。

谢谢!

1 个答案:

答案 0 :(得分:2)

你需要这样做:

... WHERE animalName LIKE '%' || ? || '%' OR trait LIKE '%' || ? || '%'

||是字符串连接符。问号应该在引号之外。