-2

I have a field in a SQL table with the format "XXX/NAME" and I would like to replace the value and to keep only the character after "/" which means that "XXX/NAME" should become "NAME". How can I achieve this ?

Minos
  • 27
  • 6

1 Answers1

1

If you just want to remove 'XXX/' then you can use replace()

 select replace('XXX/NAME','XXX/','')new_value

Output:

new_value
NAME

If you want to keep everything after '/' in a string then SUBSTRING_INDEX() is your answer.

 select SUBSTRING_INDEX('XXX/NAME','/',-1) new_value

Output:

new_value
NAME

db<>fiddle here