select
1,2,3
from (select * from A where platform in ('1','2') and id in (大类.id,小类.id)) a
join b
on a.id=b.catetory
select id from 大类 union all select id from 小类