为什么会出现SQLiteException:near" AND"。虽然每件事都对吗?

时间:2014-03-31 12:27:20

标签: android sqlite

这是我的Logcat错误行:

03-31 17:51:53.578: E/AndroidRuntime(13202):
android.database.sqlite.SQLiteException: near
"AND": syntax error: , while compiling: 

SELECT saudamst.date AS date, saudamst.contract_no AS cno, accmst1.name AS sname,      accmst2.name AS bname, itemmst.name AS item, saudamst.quantity,saudamst.rate 
FROM saudamst join accmst accmst1 on (saudamst.seller_name = accmst1.vou) join accmst accmst2 on (saudamst.buyer_name = accmst2.vou) join itemmst on (saudamst.item = itemmst.vou)
WHERE date > ? AND date < ? AND cno=? AND sname LIKE ?% AND bname LIKE ?% AND item LIKE ?% 
ORDER BY contract_no DESC

你能跟踪错误??

2 个答案:

答案 0 :(得分:1)

LIKE ?%在语法上不正确。使用LIKE ? || '%'同时使用?占位符和%文字。

||是SQL中的字符串连接运算符。

答案 1 :(得分:0)

你能用这个:

"anything LIKE '%"