Invalid mix sort error in mysql query

Is there a way to compare a column of a generated range in a mysql query?

SELECT ue.bundle,ue.timestamp,b.id,bv.id as bundleVersionId,bv.start_date,bv.end_date, bv.type,ue.type from (
 SELECT bundle,timestamp,tenant, case when Document_Id ='' then 'potrait'
 WHEN Document_Id<>'' then 'persisted' end   as type from uds_expanded ) ue
 JOIN bundle b on b.name=ue.bundle  join bundle_version bv on b.id=bv.bundle_id 
 WHERE ue.tenant='02306' and ue.timestamp >= bv.start_date and ue.timestamp <=bv.end_date and **ue.type=bv.type ;**

I get the following error when I try to compare types

 Error Code: 1267. Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '=' 0.000 sec
+4
source share
4 answers

Stick to one encoding / sorting for the whole system. Right now you seem to be using UTF8 in one place and latin1 in another place. Transform the latter to use UTF8 and you will be fine.

You can change the sort to UTF8 using

alter table <some_table> convert to character set utf8 collate utf8_general_ci;
+6
source

, , orm , mysql, workbench MySql, - . . - (, ).

:

MySQL>
MySQL> set @testCode = 'test2' collate utf8_unicode_ci;
Query OK, 0 rows affected (0.00 sec)

MySQL> select * from test where code = @testCode;

+4

, .

, Doctrine VARCHAR CHARACTER SET utf8 COLLATE utf8_unicode_ci, .

:

ALTER TABLE `table` 
CHANGE COLUMN `test` `test` VARCHAR(15) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'

or in the Workbench MySql interface → right-click on the table-> Change table, and then in the interface, click on the column and change it.

0
source

Use ascii_bin where possible, it will match almost any sort.

0
source

All Articles