# CHAR Function

## Syntax

```sql
CHAR(N,... [USING charset_name])
```

## Description

`CHAR()` interprets each argument as an [INT](https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int) and returns a string consisting of the characters given by the code values of those integers. `NULL` values are skipped. By default, `CHAR()` returns a binary string. To produce a string in a given [character set](https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets), use the optional `USING` clause:

```sql
SELECT CHARSET(CHAR(0x65)), CHARSET(CHAR(0x65 USING utf8));
+---------------------+--------------------------------+
| CHARSET(CHAR(0x65)) | CHARSET(CHAR(0x65 USING utf8)) |
+---------------------+--------------------------------+
| binary              | utf8                           |
+---------------------+--------------------------------+
```

If `USING` is given and the result string is illegal for the given character set, a warning is issued. Also, if strict [SQL mode](https://mariadb.com/docs/server/server-management/variables-and-modes/sql_mode) is enabled, the result from `CHAR()` becomes `NULL`.

## Examples

```sql
SELECT CHAR(77,97,114,'105',97,'68',66);
+----------------------------------+
| CHAR(77,97,114,'105',97,'68',66) |
+----------------------------------+
| MariaDB                          |
+----------------------------------+

SELECT CHAR(77,77.3,'77.3');
+----------------------+
| CHAR(77,77.3,'77.3') |
+----------------------+
| MMM                  |
+----------------------+
1 row in set, 1 warning (0.00 sec)

Warning (Code 1292): Truncated incorrect INTEGER value: '77.3'
```

## See Also

* [Character Sets and Collations](https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets)
* [ASCII()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii) - Return ASCII value of first character
* [ORD()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/ord) - Return value for character in single or multi-byte character sets
* [CHR](https://mariadb.com/docs/server/reference/sql-functions/string-functions/chr) - Similar, Oracle-compatible, function

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
