有没有方法比较mysql查询中生成的range列?
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 ;**当我试图比较类型时,我会得到以下错误
Error Code: 1267. Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '=' 0.000 sec发布于 2013-10-28 14:02:36
对整个系统坚持一种编码/校对。现在,您似乎在使用UTF8,在另一个地方使用latin1。将后者也转换为使用UTF8,您将很好。
可以将排序规则更改为UTF8
alter table <some_table> convert to character set utf8 collate utf8_general_ci;发布于 2014-08-30 01:15:10
我认为有时问题是我们使用不同的orm实用程序来生成表,然后我们希望通过mysql命令行或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;发布于 2016-08-02 13:36:10
请注意,单个列可以有它们的排序规则。
例如,Doctrine以CHARACTER SET utf8 COLLATE utf8_unicode_ci的形式生成VARCHAR类型的列,而更改表排序规则不会影响单个列。
可以使用以下命令更改列的排序规则:
ALTER TABLE `table`
CHANGE COLUMN `test` `test` VARCHAR(15) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'或者在MySql工作台接口中->右键单击表-> Alter,然后在接口中单击列并修改它。
https://stackoverflow.com/questions/19636743
复制相似问题