Name
EXPORT_SET()
Synopsis
EXPORT_SET(number
,on
,off
[,separator
,[count
]])
This function returns a series of strings in order that
represent each bit of a given number
. The second argument
specifies a string to represent bits that are 1 (an
on bit), and the third argument specifies a
string to represent bits that are 0 (an off bit).
The fourth argument may specify a separator, and the last argument may
specify a number of bit equivalents to display. The default separator
is a comma. Here is an example:
SELECT BIN(4) AS 'Binary Number', EXPORT_SET(4, 'on', 'off', '-', 8) AS 'Verbal Equivalent'; +---------------+--------------------------------+ | Binary Number | Verbal Equivalent | +---------------+--------------------------------+ | 100 | off-off-on-off-off-off-off-off | +---------------+--------------------------------+
Notice that the lowest-order bit is displayed first, so the
conversion of the binary equivalent of 4 is displayed by
EXPORT_SET()
in what one might consider
reverse order, from right to left: not 100, but 001 (or, as part of 8
bits, 00100000).
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.