簡單寫了兩條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 '='
本意是想定義一個變量,然后在之后執(zhí)行的多條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;
執(zhí)行時卻遇到了本文一開始時的問題。
解決辦法:
set collation_connection='utf8_unicode_ci';
show variables like 'collation_%';
再次執(zhí)行,搞定