In my database I have 1000+ rows of data that I need to modify a bit. The content column. I’ve given it try and the closest i’ve come was using RPAD
UPDATE TABLE_NAME SET content = RPAD("mySlides/", LENGTH(username)+9, username);
Using RPAD remove all the text after though, so I believe RPAD isn’t the way to go about this.
I’m trying to insert the username column after the "mySlides/" text but also not to remove the following text after. Just place right in between.
Is this possible?
Here is an example I mocked up.
Any help is appreciated!
2
Answers
One way to achieve this is by using the
CONCAT
function.Here an exemple :
Explanation
INSTR()
is used to finds the position of the first occurrence of ‘/’.SUBSTRING()
extracts the substring of the content column starting from the position after the first occurrence of the character ‘/’ till the end of the string.db fiddle: https://www.db-fiddle.com/f/fpoiGLnEzFQAmFRkkibEWn/1