I am writing a query that not work correctly
My query:
SELECT *
FROM admin_marker
WHERE admin_marker.city NOT IN (SELECT target FROM messsage)
It says
#1267 - Illegal mix of collations
(utf8_general_ci,IMPLICIT) and
(utf8_unicode_ci,IMPLICIT) for operation '='
In MySQL, you can use the <> or != operators to test for inequality in a query. For example, we could test for inequality using the <> operator, as follows: SELECT * FROM contacts WHERE last_name <> 'Johnson';
The symbol <> in MySQL is same as not equal to operator (!=). Both gives the result in boolean or tinyint(1). If the condition becomes true, then the result will be 1 otherwise 0.
not equal to (<>, !=) operator. MySQL Not equal is used to return a set of rows (from a table) after making sure that two expressions placed on either side of the NOT EQUAL TO (<>) operator are not equal. Syntax: <>, != MySQL Version: 5.6.
The problem you are facing is due to incompatible collations between the two tables. One way to come around it is to use COLLATE
clause in your query:
SELECT *
FROM admin_marker
WHERE admin_marker.city NOT IN (SELECT target COLLATE utf8_general_ci
FROM messsage)
Demo here
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