在我的android应用程序中,我使用Sqliteopenhelper来操作sqlite数据库。我需要用另一个字段(f2)的一部分来更新表中的字段(F2),用于满足特定条件的所有记录。在标准sql中可以将其编写为
update table1 set f1=substr(f2,1,length(f2)-3) where f1 like 'xxx%';不知道如何在sqliteopenhelper中这样做。谢谢
发布于 2013-11-19 19:17:43
Android的update类的SQLiteDatabase方法将要求您使用ContentValues,它只支持文字值,而不支持任意的ContentValues表达式。
只需使用execSQL
db.execSQL("UPDATE table1 SET f1=substr(f2,1,length(f2)-3) WHERE f1 like ? || '%'",
new Object[] { "xxx" });https://stackoverflow.com/questions/20079072
复制相似问题