bitmap_from_string

description

Syntax

BITMAP BITMAP_FROM_STRING(VARCHAR input)

Convert a string into a bitmap. The input string should be a comma separated unsigned bigint (ranging from 0 to 18446744073709551615). For example: input string “0, 1, 2” will be converted to a Bitmap with bit 0, 1, 2 set. If input string is invalid, return NULL.

example

  1. mysql> select bitmap_to_string(bitmap_empty());
  2. +----------------------------------+
  3. | bitmap_to_string(bitmap_empty()) |
  4. +----------------------------------+
  5. | |
  6. +----------------------------------+
  7. mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2"));
  8. +-------------------------------------------------+
  9. | bitmap_to_string(bitmap_from_string('0, 1, 2')) |
  10. +-------------------------------------------------+
  11. | 0,1,2 |
  12. +-------------------------------------------------+
  13. mysql> select bitmap_from_string("-1, 0, 1, 2");
  14. +-----------------------------------+
  15. | bitmap_from_string('-1, 0, 1, 2') |
  16. +-----------------------------------+
  17. | NULL |
  18. +-----------------------------------+
  19. mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615"));
  20. +--------------------------------------------------------------------+
  21. | bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) |
  22. +--------------------------------------------------------------------+
  23. | 0,1,18446744073709551615 |
  24. +--------------------------------------------------------------------+

keywords

  1. BITMAP_FROM_STRING,BITMAP