Here is my query:
INSERT INTO location_province(name, country)
SELECT child.name
,location_country.id
FROM location_1 child
INNER JOIN location_1 parent
ON child.parent_id = parent.id
INNER JOIN location_country
ON location_country.name = parent.name
WHERE child.location_type = 1
It throws this error:
#1267 - Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
What's wrong and how can I fix it?
Note: Adding COLLATE utf8_unicode_ci
in the end of query doesn't work either.
In short: utf8_unicode_ci uses the Unicode Collation Algorithm as defined in the Unicode standards, whereas utf8_general_ci is a more simple sort order which results in "less accurate" sorting results. If you don't care about correctness, then it's trivial to make any algorithm infinitely fast.
utf8_general_ci is a legacy collation that does not support expansions, contractions, or ignorable characters. It can make only one-to-one comparisons between characters.
utf8mb4_unicode_ci , which uses the Unicode rules for sorting and comparison, employs a fairly complex algorithm for correct sorting in a wide range of languages and when using a wide range of special characters.
Yeah, that's because of the JOIN ON
clauses and per error, collation of those columns involved in ON
condition doesn't matches. Collation of those column must match. I mean the below lines
ON child.parent_id = parent.id ------ 1
INNER JOIN location_country
ON location_country.name = parent.name ------ 2
Check the tables on which you are joining and verify the same
Well, change the collation while joining like
INNER JOIN location_country
ON location_country.name collate utf8_general_ci = parent.name collate utf8_general_ci
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With