SUBSTR(x,a,b) is a
string function that outputs part of x ( character string with length n).|
Result of the SUBSTR(x,a,b) function | |
SUBSTR(x,a,b) |
Part of the character string x that starts at the ath character and is b characters long. |
SUBSTR(x,a) |
SUBSTR(x,a,n-a+1) supplies all of the characters in the character string x from the ath character to the last (n th) character. |
b is an unsigned integer |
SUBSTR(x,a,b) b can also have a value that is greater than (n-a+1). |
b is not an unsigned integer |
SUBSTR(x,a,b) b must not be greater than (n-a+1). |
b>(n-a+1) |
SUBSTR(x,a) As many blanks (code attribute ASCII, EBCDIC) or binary zeros (code attribute BYTE) are appended to the end of this result as are needed to give the result the length b. |
x, a or b is the NULL value |
NULL value (see data type) |

Model table:
The SUBSTR function is used to reduce the firstname to one letter, add a period and a blank, and then concatenate it with the name.
SELECT SUBSTR (firstname,1,1)&'. '&name name, city
FROM customer WHERE firstname IS NOT NULL
NAME |
CITY |
J. Porter |
New York |
?. DATASOFT |
Dallas |
P. Brown |
Hollywood |
M. Jackson |
Washington |
G. Howe |
New York |
F. Miller |
Chicago |
R. Brown |
Hollywood |
S. Murphy |
Denver |
B. Smith |
San Francisco |
A. Jones |
Hollywood |
F. O’Brien |
Washington |
P. Johnson |
Chicago |
E. Thomas |
Denver |