> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# bitmap_from_string

> Converts a string into a BITMAP.

Converts a string into a BITMAP. The string is composed of a set of UINT64 numbers separated by commas. For example, the "0, 1, 2" string will be converted into a Bitmap, in which bits 0, 1 and 2 are set. If the input field is invalid, NULL will be returned.

This function deduplicates the input string during the conversion. It must be used with other functions, such as [bitmap\_to\_string](/documents/4.2/sql-reference/sql-functions/bitmap-functions/bitmap_to_string.md) to return results on terminals.

## Syntax

```Haskell theme={null}
BITMAP BITMAP_FROM_STRING(VARCHAR input)
```

## Return value

Returns a BITMAP value. If the input string is invalid, NULL is returned. If the input string is empty, an empty value is returned.

## Examples

```Plain Text theme={null}
-- The input is empty and an empty value is returned.
MySQL > select bitmap_to_string(bitmap_empty());
+----------------------------------+
| bitmap_to_string(bitmap_empty()) |
+----------------------------------+
|                                  |
+----------------------------------+

-- `0,1,2` is returned.
MySQL > select bitmap_to_string(bitmap_from_string("0, 1, 2"));
+-------------------------------------------------+
| bitmap_to_string(bitmap_from_string('0, 1, 2')) |
+-------------------------------------------------+
| 0,1,2                                           |
+-------------------------------------------------+

-- `-1` is an invalid input and NULL is returned.

MySQL > select bitmap_to_string(bitmap_from_string("-1, 0, 1, 2"));
+-----------------------------------+
| bitmap_from_string('-1, 0, 1, 2') |
+-----------------------------------+
| NULL                              |
+-----------------------------------+

-- 2^64 is an invalid input and NULL is returned.
MySQL > select bitmap_to_string(bitmap_from_string("0, 18446744073709551616"));
+-----------------------------------------------------------------+
| bitmap_to_string(bitmap_from_string('0, 18446744073709551616')) |
+-----------------------------------------------------------------+
| NULL                                                            |
+-----------------------------------------------------------------+

-- The input string is deduplicated.

MySQL > select bitmap_to_string(bitmap_from_string("0, 1, 1"));
+-------------------------------------------------+
| bitmap_to_string(bitmap_from_string('0, 1, 1')) |
+-------------------------------------------------+
| 0,1                                             |
+-------------------------------------------------+
```

## keywords

BITMAP\_FROM\_STRING,BITMAP


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.