数据库的整理

来源:互联网 发布:淘宝 液态金属导热片 编辑:程序博客网 时间:2024/04/28 20:23

关于最大数的查询

通过最大数查询符合的行

String sql1 = "select MAX(" + Contacts.STUDENT_SCORE + ") from " + Contacts.DB_TABLE_NAME;String sql = "select * from " + Contacts.DB_TABLE_NAME + " where " + Contacts.STUDENT_SCORE + " = (" + sql1 + ")";Cursor cursor = db.rawQuery(sql, null);if (cursor != null)    while (cursor.moveToNext()) {        String name = cursor.getString(cursor.getColumnIndex(Contacts.STUDENT_NAME));        int score = cursor.getInt(cursor.getColumnIndex(Contacts.STUDENT_SCORE));        StudentBean p = new StudentBean(name, score);        personBeans.add(p);    }

0 0
原创粉丝点击