select t3.subject_code,t3.psubject_code,t3.id
from
(
select t1.subject_code,t1.psubject_code,t1.id,
if(find_in_set( psubject_code, @pcode ) > 0, @pcode := concat( @pcode, ',', subject_code ), 0 ) as chilCode from
(select f.subject_code,f.psubject_code,f.id from psubject f where f.del_flag=0 ) t1,
( SELECT @pcode := 17010601 ) t2
) t3 where t3.chilCode !=0
仅供参考,希望对您有所帮助,感谢阅读。