String Functions
892
+ (2nd byte code * 256)
+ (3rd byte code * 256
2
) ...
If the leftmost character is not a multi-byte character,
ORD()
[891]
returns the same value as the
ASCII()
[886]
function.
mysql>
SELECT ORD('2');
-> 50
•
POSITION(substr IN str)
[892]
POSITION(substr IN str)
[892]
is a synonym for
LOCATE(substr,str)
[890]
.
•
QUOTE(str)
[892]
Quotes a string to produce a result that can be used as a properly escaped data value in an SQL
statement. The string is returned enclosed by single quotation marks and with each instance of
backslash (“
\
”), single quote (“
'
”), ASCII
NUL
, and Z preceded by a backslash. If the
argument is
NULL
, the return value is the word “NULL” without enclosing single quotation marks.
mysql>
SELECT QUOTE('Don\'t!');
-> 'Don\'t!'
mysql>
SELECT QUOTE(NULL);
-> NULL
For comparison, see the quoting rules for literal strings and within the C API in
Section 9.1.1, “String
Literals”
, and
Section 20.6.6.53, “
mysql_real_escape_string()
”
.
•
REPEAT(str,count)
[892]
Returns a string consisting of the string
str
repeated
count
times. If
count
is less than 1, returns
an empty string. Returns
NULL
if
str
or
count
are
NULL
.
mysql>
SELECT REPEAT('MySQL', 3);
-> 'MySQLMySQLMySQL'
•
REPLACE(str,from_str,to_str)
[892]
Returns the string
str
with all occurrences of the string
from_str
replaced by the string
to_str
.
REPLACE()
[892]
performs a case-sensitive match when searching for
from_str
.
mysql>
SELECT REPLACE('www.mysql.com', 'w', 'Ww');
-> 'WwWwWw.mysql.com'
This function is multi-byte safe.
•
REVERSE(str)
[892]
Returns the string
str
with the order of the characters reversed.
mysql>
SELECT REVERSE('abc');
-> 'cba'
This function is multi-byte safe.
•
RIGHT(str,len)
[892]
Returns the rightmost
len
characters from the string
str
, or
NULL
if any argument is
NULL
.
mysql>
SELECT RIGHT('foobarbar', 4);
-> 'rbar'
This function is multi-byte safe.
•
RPAD(str,len,padstr)
[892]
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...