Mark
Mark

Reputation: 2542

sqlite query help

Im looking to do a replacement of part of a string in sqlite. Substr

I have a table with a column called name.

Where ever the name starts with Matt, I want to replace it with John.

For example: "Matt Smith" goes to "John Smith"

Upvotes: 0

Views: 68

Answers (2)

Mikael Östberg
Mikael Östberg

Reputation: 17146

Replace would actually give you exactly that

REPLACE("Matt Smith", "Matt", "John")

Upvotes: 1

Yashima
Yashima

Reputation: 2238

You might try this:

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);

Upvotes: 0

Related Questions