select * from attachments where container_type='Shixun' and container_id in(select distinct(c.id) from subjects s join stage_shixuns ss on ss.subject_id = s.id join shixun_mirror_repositories smr on smr.shixun_id = ss.shixun_id join mirror_repositories mr on mr.id = smr.mirror_repository_id join challenges c on c.shixun_id = ss.shixun_id where s.id in(406, 51, 388, 408, 413, 411, 412, 410, 405, 407, 414));