EXPORT_SET( )

This MySQL function returns a series of strings in order that represent each bit of a given number.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

EXPORT_SET(number, on, off[, separator,[count]])

Explanation

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). A separator may be specified in the fourth argument, and a number of bit equivalents to display for the last argument. The default separator is a comma.

Examples

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).