# COLLATION

## Syntax

```sql
COLLATION(str)
```

## Description

Returns the collation of the string argument. If `str` is not a string, it is considered as a binary string (so the function returns 'binary'). This applies to `NULL`, too. The return value is a string in the utf8 [character set](https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets).

See [Character Sets and Collations](https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets).

## Examples

```sql
SELECT COLLATION('abc');
+-------------------+
| COLLATION('abc')  |
+-------------------+
| latin1_swedish_ci |
+-------------------+

SELECT COLLATION(_utf8'abc');
+-----------------------+
| COLLATION(_utf8'abc') |
+-----------------------+
| utf8_general_ci       |
+-----------------------+
```

## See Also

* [String literals](https://mariadb.com/docs/server/reference/sql-structure/sql-language-structure/string-literals)
* [CAST()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast)
* [CONVERT()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/convert)

<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" %}
