我有subquery sqlite
:
SELECT BookDB.ArticleID,BookDB.Title, subquery.Title FROM BookDB, (SELECT
MetaDataID,Title FROM MetaDataDB order by OrderView) subquery WHERE
subquery.MetaDataID = BookDB.ArticleID;
这个query
让我得到了结果(在编辑sqlite
中),但我无法在cursor
的android中看到任何结果。
cursor = sql.rawQuery("SELECT BookDB.ArticleID,BookDB.Title, subquery.Title FROM BookDB, (SELECT
MetaDataID,Title FROM MetaDataDB order by OrderView) subquery WHERE
subquery.MetaDataID = BookDB.ArticleID;", null);
if (cursor != null) {
do {
cursor.moveToFirst();
String C = cursor.getString(cursor.getColumnIndex("BookDB.Title"));
Log.i("results",C);
} while (cursor.moveToNext());
}
注意:我如何从这一行获得结果?
String C = cursor.getString(cursor.getColumnIndex("BookDB.Title"));
答案 0 :(得分:1)
我改变了我的Query
并且它有效:
cursor = sql.rawQuery("SELECT BookDB.ArticleID as ID,BookDB.Title as TITLE, subquery.Title as COMM FROM BookDB, (SELECT
MetaDataID,Title FROM MetaDataDB order by OrderView) subquery WHERE
subquery.MetaDataID = BookDB.ArticleID;", null);
if (cursor != null) {
do {
cursor.moveToFirst();
String C = cursor.getString(cursor.getColumnIndex("TITLE"));
Log.i("results",C);
} while (cursor.moveToNext());
}
立即获取结果。