【 TiDB 使用环境】生产环境 /测试/ Poc
【 TiDB 版本】5.4
【复现路径】sql 同一张表 自关联 查询
【遇到的问题:问题现象及影响】
sql 如下:
SELECT
a.id,
(
SELECT
IFNULL( sum( c.val2 ), 0 )
FROM
fac_app_data_table_field_val c
WHERE
c.val0 = a.id
AND c.table_id = 1969241186793349598
) AS r15
FROM
fac_app_data_table_field_val a
LEFT JOIN fac_app_data_table_field_val b ON a.id = b.val0
AND b.table_id = 1969243196838052179
AND b.school_id = ‘22’
AND b.flg = ‘Y’
AND b.source = ‘1’
LEFT JOIN fac_app_data_table_field_val e ON a.id = e.val0
AND e.table_id = 1969241186793349598
AND e.school_id = ‘22’
AND e.flg = ‘Y’
AND e.source = ‘1’
LEFT JOIN dictionary_info c ON a.val6 = c.id
AND c.schoolid = ‘22’
AND c.flg = ‘Y’
LEFT JOIN dictionary_info d ON a.val18 = d.id
AND d.schoolid = ‘22’
AND d.flg = ‘Y’
LEFT JOIN user_info ui ON a.val21 = ui.id
AND ui.schoolid = ‘22’
AND ui.flg = ‘Y’
WHERE
a.table_id = 1969243196838052093
AND a.school_id = ‘22’
AND a.flg = ‘Y’
AND a.source = ‘1’
AND a.val6 IN ( ‘中标销售合同’, ‘服务销售合同’ )
and
IF
( ‘blank’ = ‘学校内涵式发展平台’, 1 = 1, a.val3 LIKE concat( ‘%’, ‘学校内涵式发展平台’, ‘%’ ) )
GROUP BY
a.id
问题 如果将 c.val0 = a.id 修改为 CONVERT ( c.val0, SIGNED ) = a.id 那么该条记录1能够正确,但是该列表中记录2 又发生错误,再次改为 c.val0 = a.id 时,记录2能够正确,但是 记录1 又错误了
id 为 bigint 类型 val0为 varchar类型
【资源配置】进入到 TiDB Dashboard -集群信息 (Cluster Info) -主机(Hosts) 截图此页面
【附件:截图/日志/监控】