mysql - sql - remove char from all names of objects in database -
i trying remove name_
part of each name in database, name_
mistakenly inserted db , in 30 object names. if remove manuelly db, takes me time.
one example is: name_john
. should john
.
how can delete name_
names of objects in db sql statement?
if column values need modify, use replace()
function this:
update tablename set columnname = replace(columnname, 'name_', '') columnname '%name\_%' escape '\' ;
that remove entries of name_
in columnname
. if there can no more 1 entry (or if 1 needs removed) , position fixed, use insert()
function instead, which, despite name, can replace , delete substrings. how use if position of name_
e.g. @ beginning:
update tablename set columnname = insert(columnname, 1, 5, '') columnname 'name\_%' escape '\' ;
Comments
Post a Comment