substring (parameter 1, parameter 2, parameter 3), wherein the three parameters represent: 1 represents the need to intercept parameter string parameter 2 from that represents the start position of the string taken (subscript string starting from 1), the parameters 3 shows the number of bits to be intercepted, if you do not write, represents the beginning of the rest of the interception from the location specified parameters 2 all characters.
E.g:
- select substring ( "jason", 1,2 );
results: ja - select substring ( "jason", 1 );
results: jason - select substring ( "jason", 2 );
results: ason
These are parameters for the case of a positive number. Circumstances then when parameter 2 is negative it? Note that the argument is a 3-digit intercepted, it can not be negative, if negative, the query result will be null.
The following is the case when parameter 2 is negative
- select substring ( "jason", - 1);
Results as follows: n
taken Thought: Starting from the forward end of the string taken. - select substring ( "jason", - 3);
results: son - select substring ( "jason", - 3,1);
the result is: s
interception thought: if there is 3 digits parameter specifies the need to intercept, then from left to right beginning from the first interception is to end, rather than from Last to first start. - select substring ( "jason", - 3,2);
the result is: so - select substring ( "jason", - 3, -1);
the result is: null - select substring ( "jason", - 3,0);
the result is: null