`
usenrong
  • 浏览: 521525 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

mysql 字符串=比较 Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_gene

 
阅读更多

MySQL进行字符串比较时发生错误:

SELECT
	a.equ_no,
	b.fullCode
FROM
	equipment a,
	(
		SELECT
			t.*, getEquTypeFullCode (t.equType_id) AS fullCode
		FROM
			equ_type t
	) b
WHERE
	substring(a.equ_no, 1, 5) = b.fullCode

 错误如下: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

解决方法:将比较等式一边进行字符串转换,如改为“CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci

 

UPDATE template_messag_doctor a SET a.sended=1 where  EXISTS (select 1 from template_messag_exclude_openid b where a.openid = CONVERT(b.openid USING utf8) COLLATE utf8_unicode_ci  ) 

 

SELECT
	a.equ_no,
	b.fullCode
FROM
	equipment a,
	(
		SELECT
			t.*, getEquTypeFullCode (t.equType_id) AS fullCode
		FROM
			equ_type t
	) b
WHERE
	substring(a.equ_no, 1, 5) = CONVERT(b.fullCode USING utf8) COLLATE utf8_unicode_ci;

 

UPDATE template_messag_doctor a SET a.sended=1 where  EXISTS (select 1 from template_messag_exclude_openid b where a.openid = CONVERT(b.openid USING utf8) COLLATE utf8_unicode_ci  ) 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics