I have a large DB where I would like to change fields beginning with "BA" to "Ba".
The records typically have more information, like "BA 1234567". I would like to change this to "Ba 1234567".
How to I compose an SQL query to search through records, find those that start with "BA" and change only that part to "Ba"?
How to update part of a field?
Moderator: General Moderators
First, you will need to use BINARY operator to do case-sensitive search, like:
then you would compose your replacement string using 'Ba' prefix and source string without 2 leading characters:
Code: Select all
... where left(binary fieldname, 2) = 'BA'Code: Select all
... fieldname = concat('Ba', substring(fieldname, 3)) ...