MySQL中select语句查询不到数据的问题

MySQL中select语句查询不到数据的问题

用下面的SQL查不出数据

select sum(b.zj),b.ysxxh from uf_xtyyxmkp a,uf_xtyyxmkp_dt4 b where a.id=b.mainid and  b.ysxxh in (select group_concat(id) as id from FnaBudgetfeeType where supsubject in(select supsubject from FnaBudgetfeeType where id='968') and id <> '968') and a.id='19' and a.hsn='2022' GROUP BY b.ysxxh

img

子查询中是有查出数据的

select group_concat(id) as id from FnaBudgetfeeType where supsubject in(select supsubject from FnaBudgetfeeType where id='968') and id <> '968'

下图为其中子查询查出的结果

img

将子查询的结果单独复制进上面的SQL中也可以正常查出数据

select sum(b.zj),b.ysxxh from uf_xtyyxmkp a,uf_xtyyxmkp_dt4 b where a.id=b.mainid and  b.ysxxh in (904,917,920,952,971,997,1002,1005,1008,1016,1019,1022) and a.id='19' and a.hsn='2022' GROUP BY b.ysxxh

img

麻烦帮忙看下为什么吗?

使用in的话 直接 根据id去查不就好了么,使用group_concat干什么呢,group_concat运行出来的是逗号拼接的字符串,怎么会查到数据呢

select sum(b.zj),b.ysxxh from uf_xtyyxmkp a,uf_xtyyxmkp_dt4 b where a.id=b.mainid and  b.ysxxh in 
(select  id as id from FnaBudgetfeeType where supsubject in(select supsubject from FnaBudgetfeeType where id='968') and id <> '968')
and a.id='19' and a.hsn='2022' GROUP BY b.ysxxh


group_concat函数返回值mysql会当成字符串的, in是按照,分割 匹配第一个后其他全部截取掉了 非得这么用就find_in_set