when i execute this query i get 'android.database.sqlite.SQLiteException: no such column' what is the error?
public Cursor Getupdate(String rid) throws SQLException
{
Cursor m1Cursor = db.rawQuery("SELECT _id FROM Meeting where meet="+rid , null);
if (m1Cursor != null) {
if(m1Cursor.getCount() > 0)
{
m1Cursor.moveToFirst();
}
}
return m1Cursor;
}
logcat
05-28 01:22:27.999: E/AndroidRuntime(1411): FATAL EXCEPTION: main
05-28 01:22:27.999: E/AndroidRuntime(1411): android.database.sqlite.SQLiteException: no such column: ttyuhomk: , while compiling: SELECT _id FROM Meeting where meet=rage
For string data type always use quotes like this '"+rid+"'" since rid is String you get error.
You should use +rid only if rid is int.
您需要在 Where 子句检查中使用撇号(') .. 喜欢
db.rawQuery("SELECT _id FROM Meeting where meet='"+rid+"'" , null);
You can also use like this.
db.rawQuery("SELECT _id FROM Meeting where meet=?" ,
new String [] {rid});
This will also solve for SQL injection problem.
Or, better yet, use a PreparedStatement and bind your variables. It'll escape strings and dates properly for you. It'll also help with SQL injection problems.
'<YOUR_ID_TO_MATCH_WITH>'
)In case the above answers are still unclear, just use single quotes to surround the where clause.
Eg: db.update(TABLE_USER,contentValues, "$KEY_TOKEN='${token}'",null)
Notice the quotes in '$token'
. That's just it! 😄
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.