如下SQL,t1有2行结果。
t2取自varchar字段,但关联后会发散
实际代码t1取自表,还会出现,关联后取不到结果的情况
查看执行计划发现,隐匿转换 bigint as double,应该是有效位不够导致t2中接近的数字同化了
这个隐式转换逻辑不对,不能单纯看左侧?
select t1.* ,
t2.code
from (
select cast(1037773994249297944 as bigint) as id ,
1 as flag
union all
select cast(1037773994249297944 as bigint) as id ,
2 as flag
) as t1
inner join (
select '1037773994249297944' as code
union all
select '1037773994249297941' as code
) t2
on t1.id = t2.code