0
我有一個相當大的查詢,當在android外部執行時返回數據,而在android中執行時沒有返回任何內容。Android開發與SQLite的:查詢結果不應該是空的
- 我把這個查詢分成幾部分,確定工會沒問題。
- 我嘗試了一組具有相同行爲的較小數據。
- 我測試過不同的硬件和API版本。
- 我使用帶有常量值的rawQuery方法。 http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#rawQuery(java.lang.String, java.lang.String[])
此查詢是爲了替換當前不支持的FULL OUTER JOIN。
SELECT IFNULL(stype, gtype) AS type, IFNULL(sdate, gdate) AS date, IFNULL(sroute, groute) AS route FROM (
SELECT sp.type AS stype, sp.date AS sdate, -1 AS gtype, gp.date AS gdate, sp.route AS sroute, gp.route AS groute
FROM Sensor_Point AS sp LEFT JOIN GPS_Point AS gp ON gp._id IS NULL AND sp.sent=0 AND sp.route=gp.route AND sp.route=1
UNION ALL
SELECT sp.type AS stype, sp.date AS sdate, -1 AS gtype, gp.date AS gdate, sp.route AS sroute, gp.route AS groute
FROM GPS_Point AS gp LEFT JOIN Sensor_Point AS sp ON sp._id IS NULL AND gp.sent=0 AND sp.route=gp.route AND gp.route=1
) WHERE route=1 ORDER BY date ASC LIMIT 255
任何提示將不勝感激。
更新:
看的像問題終於與查詢參數,如果我這樣設置:
String[] args = new String[3];
args[0] = args[1] = args[2] = "1";
Cursor data dataBase.rawQuery(SELECT_POINTS, args);
它不工作,而直接硬編碼值時,工作在查詢中。
Cursor data = dataBase.rawQuery(SELECT_POINTS, null);
非常感謝@CL。就是這個 !!我首先想到這個問題與嵌套查詢有關,因爲子查詢沒有任何投射就能正常工作,但我錯了。 – annoyed 2013-04-24 08:11:20