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 ?
Asked
Active
Viewed 47 times
1 Answers
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
Kazi Mohammad Ali Nur
- 13,391
- 2
- 11
- 23