我已经在SQLite中测试了这个选择,它可以工作,但是当我在Android中使用它时,它返回0。
我要去哪里错了?
谢谢!!
final String idauto = bundle.getString("idtabella");
DatabaseHelper databaseHelper = new DatabaseHelper(this);
final SQLiteDatabase db = databaseHelper.getReadableDatabase();
final Cursor cursordati = db.rawQuery("SELECT MAX('in_auto') AS in_auto "
+ "FROM inout WHERE id_auto ='" + idauto + "'", null);
final int Ingressi = cursordati.getColumnIndex("in_auto");
if(cursordati.moveToFirst()){
TextV.append("iprova: "+ Ingressi);
do {
TextV.append("dprova: "+ Ingressi);
} while (cursordati.moveToNext());
TextV.append("wprova: "+ Ingressi);
}
最佳答案
刚放
cursordati.moveToFirst();
之前
final int Ingressi = cursordati.getInt(0);
有用 :)
关于java - Android SELECT MAX不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6213760/