如果有人能告诉我更新sqlite
中表格的正确语法,将会很有帮助。
我想使用sqlite
更新表格,但我收到以下错误:
android.database.sqlite.SQLiteException:接近“ON”:语法错误(代码1):,同时编译:INSERT INTO cost(service_type,cost)VALUES('1000','Oil and Filter Change')ON DUPLICATE KEY UPDATE service_type ='Oil and Filter Change',cost ='1000';
代码:
public void UpdatePrice(String ser_type, String cost)
{
String query = "INSERT INTO " + TABLE_COST +
" (" + COLUMN_SERVICE_TYPE + "," + COLUMN_COST +") VALUES('"+
cost + "','" +ser_type +"') ON DUPLICATE KEY UPDATE "+
COLUMN_SERVICE_TYPE + "='" + ser_type + "',"+
COLUMN_COST + "='" + cost + "';";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query, null);
// Move to first row
cursor.moveToFirst();
cursor.close();
db.close();
}