1268
MariaDBERRORNotableCharacter SetsHIGH confidence
Illegal mix of collations for operation
Production Risk
Medium — queries fail; joins and comparisons on text columns may be broken.
What this means
ER_CANT_AGGREGATE_2COLLATIONS (1268, SQLSTATE HY000) is raised when MySQL cannot determine a single collation to use for a string operation involving two columns or expressions with incompatible collations.
Why it happens
- 1Comparing or concatenating columns with different collations (e.g., utf8_general_ci vs utf8_unicode_ci)
- 2Joining tables where the key columns have different collations
- 3Using CONCAT or comparison operators on strings with mismatched collations
How to reproduce
trigger — this will error
trigger — this will error
SELECT * FROM t1 JOIN t2 ON t1.name COLLATE utf8_general_ci = t2.name COLLATE utf8_unicode_ci; -- ERROR 1268 if collations conflict without explicit resolution
expected output
ERROR 1268 (HY000): Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
Fix 1
Explicitly cast one operand to the other collation
Explicitly cast one operand to the other collation
SELECT * FROM t1 JOIN t2 ON t1.name = t2.name COLLATE utf8_general_ci;
Why this works
Using COLLATE to explicitly specify the desired collation resolves the ambiguity.
Fix 2
Standardize collations across tables
Standardize collations across tables
ALTER TABLE t2 MODIFY name VARCHAR(100) COLLATE utf8_general_ci;
Why this works
Making collations consistent across related columns avoids the error entirely.
Sources
Official documentation ↗
MySQL 8.0 — 1268 ER_CANT_AGGREGATE_2COLLATIONS
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev