I have a character string and for reporting/alignment purpose I need to insert a space after each character. Unfortunately I will have to do it in a SQL or I can write format function.
e.g. “abcd123” to be converted it to “a b c d 1 2 3 “.
Since it’s for a considerable number of rows I was wondering how optimized it will be to parse each character and build a new string each time?
Any help is appreciated.
Thanks
Here’s a quick & dirty mysql function which solves your problem:
Now try this:
which returns
“a b c d 1 2 3”
This function basically loops for each character and concats a space. Direction is from end to beginning, which saves a counter variable.
I havn’t done any performance test, fur sure you somehow could optimize this..