select * from (select * from a union all select * from b) T where name in (select name from a where name in( select name from b));
已经经过测试。