Oracle 5.0 Reference Manual page 914

Table of Contents

Advertisement

SUBSTR(str,pos)
SUBSTR(str FROM pos FOR len)
[894]
is a synonym for
SUBSTR()
SUBSTRING(str,pos)
SUBSTRING(str,pos,len)
The forms without a
The forms with a
len
position pos. The forms that use
value for pos. In this case, the beginning of the substring is
string, rather than the beginning. A negative value may be used for
function.
For all forms of
SUBSTRING()
substring is to be extracted is reckoned as 1.
mysql>
SELECT SUBSTRING('Quadratically',5);
-> 'ratically'
mysql>
SELECT SUBSTRING('foobarbar' FROM 4);
-> 'barbar'
mysql>
SELECT SUBSTRING('Quadratically',5,6);
-> 'ratica'
mysql>
SELECT SUBSTRING('Sakila', -3);
-> 'ila'
mysql>
SELECT SUBSTRING('Sakila', -5, 3);
-> 'aki'
mysql>
SELECT SUBSTRING('Sakila' FROM -4 FOR 2);
-> 'ki'
This function is multi-byte safe.
If
is less than 1, the result is the empty string.
len
SUBSTRING_INDEX(str,delim,count)
Returns the substring from string
is positive, everything to the left of the final delimiter (counting from the left) is returned. If
is negative, everything to the right of the final delimiter (counting from the right) is returned.
SUBSTRING_INDEX()
mysql>
SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
-> 'www.mysql'
mysql>
SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);
-> 'mysql.com'
This function is multi-byte safe.
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
[894]
FROM] str)
Returns the string
str
LEADING, or
TRAILING
are removed.
mysql>
SELECT TRIM('
-> 'bar'
mysql>
SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx');
-> 'barxxx'
mysql>
SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');
-> 'bar'
mysql>
SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
-> 'barx'
String Functions
[894],
SUBSTR(str FROM pos)
[894]
SUBSTRING()
[894],
SUBSTRING(str FROM pos)
[894],
SUBSTRING(str FROM pos FOR len)
argument return a substring from string
len
argument return a substring
are standard SQL syntax. It is also possible to use a negative
FROM
[894], the position of the first character in the string from which the
before
str
[894]
performs a case-sensitive match when searching for delim.
with all
prefixes or suffixes removed. If none of the specifiers BOTH,
remstr
is given,
is assumed.
BOTH
bar
');
894
[894],
SUBSTR(str,pos,len)
[894].
[894],
str
characters long from string str, starting at
len
characters from the end of the
pos
[894]
occurrences of the delimiter delim. If
count
is optional and, if not specified, spaces
remstr
[894],
[894]
starting at position pos.
in any of the forms of this
pos
count
[894],
TRIM([remstr
count

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents