当我在我的数据库上运行以下查询时,它会给我以下错误:
android.database.sqlite.SQLiteException: near "--,COUNT(*) FROM .. with
syntax error code 1
这是我的疑问:
SQLiteDatabase db = getReadableDatabase();
final String MY_QUERY="SELECT d.* FROM deseases d where d.deseaseID in (select s.deseaseID --,COUNT(*) FROM (select distinct deseaseID, syntomDescription FROM syntoms ) S where s.syntomDescription in ("+symptoms+") group by s.deseaseID having COUNT(*)="+symptomCount+") and d.deseaseID in (select m.deseaseID FROM (select distinct deseaseID, morphologyName FROM morphology ) m where m.morphologyName in ("+morphology+") group by m.deseaseID having COUNT(*)="+morphologyCount+" ) and d.chapterID = "+category;
Cursor c = db.rawQuery(MY_QUERY, null);
请告诉我我做错了什么。
答案 0 :(得分:3)
--
在SQL中发表评论。注释之前的SQL不构成语法上有效的查询。
目前尚不清楚您实际想要实现的目标,但删除--
可能会使其在语法上有效。
答案 1 :(得分:3)
原始查询可能在COUNT(*)之后有一个换行符。
删除整个评论,即--,COUNT(*)
。