# Error 1271: Illegal mix of collations for operation

| Error Code | SQLSTATE | Error                            | Description                                  |
| ---------- | -------- | -------------------------------- | -------------------------------------------- |
| 1271       | HY000    | ER\_CANT\_AGGREGATE\_NCOLLATIONS | Illegal mix of collations for operation '%s' |

## Possible Causes and Solutions

This error occurs when attempting to combine (e.g., using UNION) two tables where the same column has different collation types. To resolve this, one of the column's collations must be adjusted to match the other.

## Diagnosing Collation Types

To identify the collation type of a column, you can use the following query:

```
SELECT COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'your_database_name'
AND TABLE_NAME = 'your_table_name';
```

For a comprehensive comparison, you might want to join `table1` and `table2` based on the `COLUMN_NAME` to visually inspect the collation differences.

## Resolving Collation Conflicts

Assuming one column is using `utf8mb3_general_ci` and the other `utf8mb3_unicode_ci`, you can standardize the collation for a particular operation as follows:

```
FROM table;
SELECT COLUMN COLLATE utf8mb3_unicode_ci
```

This command temporarily adjusts the collation for `column` during the SELECT operation to `utf8mb3_unicode_ci`, ensuring consistent collation for the operation.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @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/error-codes/mariadb-error-codes-1200-to-1299/e1271.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.
