Substring each row of a column in mySQL -
i have table column called menu_name contains string "one|two|three|four|something"
i want write 1 time script remove after , including last |
so final value "one|two|three|four"
if there no | in cell, i.e "something" want set string ""
thanks!
thanks nanhe kumar getting me close, here's final command:
update reports set menu_name = substring(menu_name,1,position(substring_index(menu_name,'|',-1) in menu_name)-2)
select substring(menu_name,1,position(substring_index(menu_name,'|',-1) in menu_name)-2) menu table_name;
Comments
Post a Comment