String Functions
888
mysql>
SELECT 'My' 'S' 'QL';
-> 'MySQL'
•
CONCAT_WS(separator,str1,str2,...)
[888]
CONCAT_WS()
[888]
stands for Concatenate With Separator and is a special form of
CONCAT()
[887]
. The first argument is the separator for the rest of the arguments. The separator is
added between the strings to be concatenated. The separator can be a string, as can the rest of the
arguments. If the separator is
NULL
, the result is
NULL
.
mysql>
SELECT CONCAT_WS(',','First name','Second name','Last Name');
-> 'First name,Second name,Last Name'
mysql>
SELECT CONCAT_WS(',','First name',NULL,'Last Name');
-> 'First name,Last Name'
CONCAT_WS()
[888]
does not skip empty strings. However, it does skip any
NULL
values after the
separator argument.
•
ELT(N,str1,str2,str3,...)
[888]
ELT()
[888]
returns the
N
th element of the list of strings:
str1
if
N
=
1
,
str2
if
N
=
2
, and so on.
Returns
NULL
if
N
is less than
1
or greater than the number of arguments.
ELT()
[888]
is the
complement of
FIELD()
[888]
.
mysql>
SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
-> 'ej'
mysql>
SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
-> 'foo'
•
EXPORT_SET(bits,on,off[,separator[,number_of_bits]])
[888]
Returns a string such that for every bit set in the value
bits
, you get an
on
string and for every
bit not set in the value, you get an
off
string. Bits in
bits
are examined from right to left (from
low-order to high-order bits). Strings are added to the result from left to right, separated by the
separator
string (the default being the comma character “
,
”). The number of bits examined is
given by
number_of_bits
, which has a default of 64 if not specified.
number_of_bits
is silently
clipped to 64 if larger than 64. It is treated as an unsigned integer, so a value of –1 is effectively the
same as 64.
mysql>
SELECT EXPORT_SET(5,'Y','N',',',4);
-> 'Y,N,Y,N'
mysql>
SELECT EXPORT_SET(6,'1','0',',',10);
-> '0,1,1,0,0,0,0,0,0,0'
•
FIELD(str,str1,str2,str3,...)
[888]
Returns the index (position) of
str
in the
str1
,
str2
,
str3
,
...
list. Returns
0
if
str
is not found.
If all arguments to
FIELD()
[888]
are strings, all arguments are compared as strings. If all
arguments are numbers, they are compared as numbers. Otherwise, the arguments are compared
as double.
If
str
is
NULL
, the return value is
0
because
NULL
fails equality comparison with any value.
FIELD()
[888]
is the complement of
ELT()
[888]
.
mysql>
SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');
-> 2
mysql>
SELECT FIELD('fo', 'Hej', 'ej', 'Heja', 'hej', 'foo');
-> 0
•
FIND_IN_SET(str,strlist)
[888]
Returns a value in the range of 1 to
N
if the string
str
is in the string list
strlist
consisting of
N
substrings. A string list is a string composed of substrings separated by “
,
” characters. If the first
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...