我的应用程序与sql lite数据库一起使用我在SQlite开发人员中进行了wrotte查询并测试它,这是正常工作但是当我在android上编写它时,它只返回一个值为几个的值。什么是android查询错误?
程序代码
SELECT DISTINCT
m._id,
m.name,
m.the_best_time,
m.the_worse_time,
count(p._id) as qPoints
FROM sickness AS s
INNER JOIN list_of_sicknesses AS l
ON s._id = l.sickness_id
INNER JOIN point AS p
ON p.sickness_list = l.number
INNER JOIN meridian AS m
ON m._id = p.meridian_id
WHERE s.sick = 'value'
GROUP BY
m.name,
m.the_best_time,
m.the_worse_time,m._id
android查询代码
String query="select distinct m." +MeridianDB.ID+
",m."+MeridianDB.NAME+",m."+MeridianDB.BEST_TIME+
",m."+MeridianDB.WORSE_TIME+",count(p."+PointDB.ID+") as qPoints from "+
SicknessDB.TABLE_NAME+" as s inner join "+ListOFSicknessDB.TABLE_NAME+
" as l on s."+SicknessDB.ID+" = l."+ListOFSicknessDB.SICKNESS_ID+
" inner join "+PointDB.TABLE_NAME+" as p on p."+PointDB.SICKNESS_LIST+
" = l."+ListOFSicknessDB.NUMBER+" inner join "+MeridianDB.TABLE_NAME+
" as m on m."+MeridianDB.ID+" = p."+PointDB.MERIDIAN_ID+" where s."+
SicknessDB.NAME+"=? group by m."+MeridianDB.ID+",m."+MeridianDB.NAME+
",m."+MeridianDB.BEST_TIME+",m."+MeridianDB.WORSE_TIME;
答案 0 :(得分:0)
尝试删除DISTINCT
子句(因为您已经在使用GROUP BY
)
我不确定此问题是否存在,但在同一个查询中同时使用DISTINCT
和GROUP BY
通常不是最佳做法