DataBase查询在哪里

时间:2015-05-19 22:18:17

标签: android sqlite

我是移动应用程序设计的新手,我正在尝试设计一个android,我使用的是数据库sqlite,我唯一的问题是查询 我有一个表,我想选择此表中id为1的所有名称

我试过这个,但我知道这完全是假的!

"SELECT 'id' FROM 'highscores' WHERE 'account_id' = "..accID.." AND 'vocation' = "..vocation
.." AND 'monster' = "..monster

感谢您的帮助! :)

2 个答案:

答案 0 :(得分:1)

String selectQuery = "SELECT " + KEY_ARRET + " FROM " + TABLE_NAME + " WHERE _idligne = 1";

答案 1 :(得分:0)

尝试这种方式,减少行数但是相同,当然没有错误:

Cursor cursor = db.rawQuery("SELECT "+ KEY_ARRENT+" FROM "+TABLE_NAME+"WHERE _idligne = 1", null);

如果它正在工作,请试试这个:

cursor = db.rawQuery("select * from "+TABLE_NAME+" WHERE _idligne = 1", null);
String C1="";
        if (cursor.getCount() != 0) {//recorre todos los datos/campos
            if (cursor.moveToFirst()) {
                do {
                    C1 = cursor.getString(cursor
                            .getColumnIndex(KEY_ARRENT));
                } while (cursor.moveToNext());//pasa al sig dato /campo
            }
        }
        cursor.close();