简单写了两条SQL语句:
set @uuid = 'df0d97d9-357b-47e7-914a-05c2eca39349';
select * from table_name here uuid = @uuid;
报出如下错误:
Error Code: 1267. Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
本意是想定义一个变量,然后在之后执行的多条SQL里面都可以使用同一个变量的值,从而不用一次改多个值:
set @uuid='df0d97d9-357b-47e7-914a-05c2eca39349';
delete from table_name_0 here examination_uuid=@uuid;
delete from table_name_1 where examination_uuid=@uuid;
update table_name_3 set state=0, status=100 where uuid=@uuid;
执行时却遇到了本文一开始时的问题。
解决办法:
set collation_connection='utf8_unicode_ci';
show variables like 'collation_%';
再次执行,搞定
网友评论