【操作】sql联合查询
SET @m='1001';
select t.TRADE_S,t.TRADE_T,d.TRANS_N,d.TRANS_S,d.*
from db.t_main t
left join db.t_item d on t.O_ID = d.O_ID
where t.O_NO = @m;
【结果】查询报错:
Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='
【解决】在变量后指定排序类型、字符编码
COLLATE utf8mb4_unicode_ci
SET @m='1001';
select t.TRADE_S,t.TRADE_T,d.TRANS_N,d.TRANS_S,d.*
from db.t_main t
left join db.t_item d on t.O_ID = d.O_ID
where t.O_NO = @m COLLATE utf8mb4_unicode_ci;
网友评论