replace - update specific column of mysql table -
i have quite big table in mysql , need alter records related column.
records :
/name/nm0000209/?ref_=ttfc_fc_cl_t1, /name/nm0000151/?ref_=ttfc_fc_cl_t2, ..., /name/nm0104594/?ref_=ttfc_fc_cl_t10
what want maintain string in middle nm0000209
, nm0000151
,.... know how delete specific characters right or left of words replace
or trim , .., problem in case number of characters in 3rd part of string not equal (as see when reaches 10, have delete 21 characters end instead of 20 characters , since table contains lots of records dont know how it.
i reaaly appreciate if helop me,
thanks
i want maintain string in middle nm0000209, nm0000151...
you can utilize 'substring_index'
on column crop part of column value.
following illustration assumes said column have 'name/'
starting pattern.
example:
update table_name set column_name = substring_index( substring_index( column_name, 'name/', -1 ) , '/', 1 );
the same can used updating same value.
demo @ mysql fiddle
mysql replace sql-update trim
No comments:
Post a Comment