使用LIMIT的SQLite子查询在2.3设备中不起作用

时间:2014-03-28 07:34:03

标签: android database sqlite android-4.0-ice-cream-sandwich android-sdk-2.3

此查询工作4.0完美但不在2.3设备中,如果我删除LIMIT子句和子查询比在2.3设备中完美工作

2.3设备中LIMIT的问题???

在4个不同的设备中测试相同的APK 2.3只显示一个结果并非全部,4.0完美无缺

这是 fiddle

SELECT * FROM (SELECT pk_video_master_id AS _id,    
video_title AS title1,
COUNT(fk_video_master_id) AS sub_title_1,   
SUM(video_detail_length) AS sub_title_2,
-1007 AS module 
FROM tbl_video_master 
LEFT JOIN tbl_video_detail ON fk_video_master_id = pk_video_master_id
WHERE title1 LIKE '%n%' GROUP BY _id LIMIT 3) 

UNION ALL 

SELECT * FROM (SELECT pk_surveys_id AS _id ,
surveys_title AS title1,
surveys_end_date AS sub_title_1,
COUNT(fk_survey_detail_survey_id) AS sub_title_2,
-1006 AS module
FROM tbl_surveys 
LEFT JOIN tbl_survey_detail ON fk_survey_detail_survey_id = pk_surveys_id 
WHERE title1 LIKE '%n%' GROUP BY _id LIMIT 5);

帮助我...谢谢

1 个答案:

答案 0 :(得分:0)

您可以尝试 ROWID BETWEEN 1 AND 5 而不是 LIMIT

您可以选择-1006,然后也可以选择-1007。因此,您可以通过java而不是sql强制执行 LIMIT 。我的意思是不要使用 union 分别选择两个记录作为两个结果集然后 java make union results set as you want