I want to select a field from table and substring it.
For example:
VAN1031 --> 1031
I tried this, but is improper syntax:
<
You can use:
SUBSTR(string,position)
SUBSTR(string,position,length)
SUBSTRING_INDEX(string, delimiter, count)
Examples:
command prints
------------------------------------------- -----------
select substr("abcd", 1, 1) #a
select substr("abcd", 1, 2) #ab
select substr("abcd", 2, 1) #b
select substr("abcd", 2, 2) #bc
select substr("abcd", -2, 1) #c
select substr("abcd", -2, 2) #cd
select substring_index('ababab', 'b', 1); #a
select substring_index('ababab', 'b', 2); #aba
select substring_index('ababab', 'b', 3); #ababa
select substring_index('ababab', 'b', -1); #
select substring_index('ababab', 'b', -2); #ab
select substring_index('ababab', 'b', -3); #abab
select substr("abcd", 2) #bcd
select substr("abcd", 3) #cd
select substr("abcd", 4) #d
select substr("abcd", -2) #cd
select substr("abcd", -3) #bcd
select substr("abcd", -4) #abcd
From this link.