2013-11-27 37 views
-1

我有我在Android中的Android SQLite的查詢在4.0中運行而不是在2.3

SQLiteDatabase db = this.getWritableDatabase(); 
Cursor c; 

String Query = "Select * from SubCategory_List where CatId = (Select _id from Category_List where Name = ?) order by Name ASC"; 

c = db.rawQuery(Query, new String[] { CatName }); 

我用這個光標填充ListView在數據庫上運行下面的查詢。在android 4.0中,我得到了所需的輸出,但在2.3版本中並沒有顯示。

回答

0

更改此:

String Query = "Select * from SubCategory_List where CatId = (Select _id from Category_List where Name = ?) order by Name ASC"; 

本:

String Query = "Select * from SubCategory_List where CatId IN (Select _id from Category_List where Name = ?) order by Name ASC"; 

(更改=入)

+0

爲什麼 「IN」 要求?內部查詢只返回單個值。 –

相關問題