MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB EXPORT_SET() Function



The MariaDB EXPORT_SET() function returns a string which contains an on string for every bit set in the value bits, and an off string for every unset bit in the value bits.

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.

Syntax

EXPORT_SET(bits, on, off, separator, number_of_bits)

Parameters

bits Required. Specify the bits set.
on Required. Specify the list of strings.
off Required. Specify the list of strings.
separator Optional. Specify the separator string. Default is ",".
number_of_bits Optional. Specify the number of bits to be examined. Default is 64. It is clipped to 64 if larger than 64 is provided. It is treated as unsigned integer, so a value of −1 is effectively the same as 64.

Return Value

Returns a string which contains an on string for every bit set in the value bits, and an off string for every unset bit in the value bits.

EXPORT_SET() Function

Example:

The example below shows the usage of EXPORT_SET() function.

SELECT EXPORT_SET(5, 'Y', 'N', ',', 6);
Result: 'Y,N,Y,N,N,N'

SELECT EXPORT_SET(5, '1', '0', ',', 6);
Result: '1,0,1,0,0,0'

SELECT EXPORT_SET(9, 'Y', 'N', ',', 5);
Result: 'Y,N,N,Y,N'

SELECT EXPORT_SET(15, 'Y', 'N', ',', 7);
Result: 'Y,Y,Y,Y,N,N,N'

❮ MariaDB Functions