The MAKE_SET function selects and combines strings from multiple string parameters based on a bitmask (bit). Returns a comma-separated string set containing all strings whose corresponding bit is 1.
Behavior aligns with MAKE_SET in MySQL.
MAKE_SET(<bit>, <str1>[, <str2>, ...])
| Parameter | Description |
|---|---|
<bit> | Bitmask value, binary bits indicate which strings to select. Type: BIGINT |
<str1>, <str2>, ... | String parameters to be combined (variable arguments). Type: VARCHAR |
Returns VARCHAR type, a comma-separated string set.
Special cases:
<bit> is NULL, returns NULL<bit> is 0, returns empty stringSELECT make_set(3, 'dog', 'cat', 'bird');
+-----------------------------------+ | make_set(3, 'dog', 'cat', 'bird') | +-----------------------------------+ | dog,cat | +-----------------------------------+
SELECT make_set(5, NULL, 'warm', 'hot');
+---------------------------------+ | make_set(5, NULL, 'warm', 'hot') | +---------------------------------+ | hot | +---------------------------------+
SELECT make_set(0, 'hello', 'world');
+--------------------------------+ | make_set(0, 'hello', 'world') | +--------------------------------+ | | +--------------------------------+
SELECT make_set(NULL, 'a', 'b', 'c');
+-------------------------------+ | make_set(NULL, 'a', 'b', 'c') | +-------------------------------+ | NULL | +-------------------------------+
SELECT make_set(15, 'first', 'second');
+-------------------------------------+ | make_set(15, 'first', 'second') | +-------------------------------------+ | first,second | +-------------------------------------+
SELECT make_set(7, 'ṭṛì', 'ḍḍumai', 'test');
+------------------------------------------+ | make_set(7, 'ṭṛì', 'ḍḍumai', 'test') | +------------------------------------------+ | ṭṛì,ḍḍumai,test | +------------------------------------------+
MAKE_SET