java
1 2int num = tab.getnum(); 3 4SQLiteDatabase db = databaseHelper.getReadableDatabase(); 5 6String sql = "SELECT c._id, c.name, c.type1, c.type2, c.publisher, c.author, c.english, c.wikipedia, c.official, c.official2, count(c._id), count(l.information_id) " + 7 "FROM collection AS c " + 8 "INNER JOIN collection_information AS cm ON c._id=cm.collection_id " + 9 "LEFT JOIN( SELECT DISTINCT log.information_id FinformationROM log) AS l " + 10 "ON cm.information_id=l.information_id " + 11 "WHERE c.type1=? " + 12 "GROUP BY c._id;"; 13 14String[] selectionArgs ={ Integer.toString(num) }; 15Cursor cursor = db.rawQuery(sql, selectionArgs);
type1にフィルターかける為に、引数で撮ってきた引数(int型)にWHEREをしようと思います。
今回は、db.rawQueryの2つ目の引数に配列で値を与えるとsqlの「?」のところに文字を入れてくれるとの事でこんな式にしてみましたが、cursorが空のままで出てきてしまいます。
この式のどこがまずいのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/25 13:32
2016/10/25 13:41