Android 在SqLite中,当特定值的计数大于一时更新表
我有一个表,当计数大于1时,我想更新现有值 这是我的密码:Android 在SqLite中,当特定值的计数大于一时更新表,android,sqlite,sql-update,Android,Sqlite,Sql Update,我有一个表,当计数大于1时,我想更新现有值 这是我的密码: public int getCount(String clues) { Cursor c = null; try { db = this.getReadableDatabase(); String query = "select count(*) from " + TABLE_NAME + "where CLUES_VALUES = ?"; c = db.rawQue
public int getCount(String clues) {
Cursor c = null;
try {
db = this.getReadableDatabase();
String query = "select count(*) from " + TABLE_NAME + "where CLUES_VALUES = ?";
c = db.rawQuery(query, new String[] {clues});
if (c.moveToFirst()) {
return c.getInt(0);
}
return 0;
}
finally {
if (c != null) {
c.close();
}
if (db != null) {
db.close();
}
}
}
我是根据“线索与价值”一栏进行检查的。我从数据库中获取这些值,并检查它是否在“线索值”列中包含多个类似值。如果包含,则会更新整行,否则不会更新。
当我执行代码时,我得到了下面的错误
android.database.sqlite.SQLiteException: near "=": syntax error (code 1): , while compiling: select count(*) from puzzl_tablewhere CLUES_VALUES = ?
“字符串值”列包含“字符串值”
我不知道我在哪里失踪了。请帮忙。您在“where”前面缺少一个空格
我认为您缺少的只是表名后面和where前面的一个空格
String query = "select count(*) from " + TABLE_NAME + " where CLUES_VALUES = ?";
是它导致了这个错误吗@活跃的空间是原因
String query = "select count(*) from " + TABLE_NAME + " where CLUES_VALUES = ?";