简体   繁体   中英

How to get row with a specific value from a specific column in SQLite?

I save data in a SQLite Database. The user can choose under which name his data will be saved. But how to get the row?

I'm trying this:

    public Cursor getRowByName(String rowName) {
    Cursor c = db.query(true, DATABASE_TABLE, ALL_KEYS,
            KEY_SAVENAME + "=?", new String[]{rowName}, null, null, null, null);
    if (c != null) {
        c.moveToFirst();
    }
    return c;
}

But get the error:

E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.database.sqlite.SQLiteException: no such column: max (code 1): , while compiling: 
SELECT DISTINCT _id, saveName, date, time, month, erg, ergg, m, p, c, cg, x1, x2, 
x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, y1, y2, y3, y4, 
y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, c1, c2, c3, c4, c5, c6, 
c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, max, min, year FROM mainTable WHERE saveName=?

First it worked without the column max but afterwards I recognized that I need this and furthermore columns. But even if I had one more column (like max ), I get this error.

What am I doing wrong?

更改数据库结构时, 必须增加DATABASE_VERSION常量值,以便触发onUpgrade()方法(它将删除并重新创建表)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM