【发布时间】:2011-03-16 12:08:24
【问题描述】:
我希望在 sqlite 中替换部分字符串。子字符串
我有一个表,其中有一列名为 name。
名字以马特开头的地方,我想用约翰替换它。
例如: “马特史密斯”转到“约翰史密斯”
【问题讨论】:
标签: sqlite
我希望在 sqlite 中替换部分字符串。子字符串
我有一个表,其中有一列名为 name。
名字以马特开头的地方,我想用约翰替换它。
例如: “马特史密斯”转到“约翰史密斯”
【问题讨论】:
标签: sqlite
替换实际上会给你这个
REPLACE("Matt Smith", "Matt", "John")
【讨论】:
SET name = REPLACE(name, 'Matt', 'John')
你可以试试这个:
final String[] whereArgs = { "Matt%" };
final ContentValues args = new ContentValues();
args.put(NAME_COLUMN, "John");
int columnsUpdated = this.sqlitedatabase.update(YOUR_TABLE,args,"where name like ?", whereArgs);
【讨论】: