var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: substring problem
i have a string = '26453|20110411'.
how do i select first 6 character AFTER the pipe (|)?
So the output would be 201104.
Length of character before | might varies.
Last edited by reeson; 07-18-11 at
Reason: more info
There's no function to do this that I know of, but it's possible - albeit convoluted - with something like the following:
Where val is a char/varchar type in sometable.
substring_index(val, '|', 2),
length(substring_index(val, '|', 1)) + 1
I confirmed this worked with 26453|20110411 and 264531|20110411.
Seems like it works. Thanks so much
Will look up what substring_index do, never use it before.
You may have already figured this out, but for your uses it can actually be a lot simpler. The code I posted can be used to get any value in a list of delimiter-separated values.. but since you only have the 2 values separated by one delimiter, the following should work as well:
substring_index(val, '|', -1)
After going through the manual, think I got it. Pretty neat function.
I almost going to write my own function for this issue
Thanks again mate