有个关联类Link,角色分别为A与B,其中B是A的子节点,现在有一个需求,返回两级父节点的合集 
SQL如下: select parentA.id  //返回第二层父节点 
  from A parentA,B parentB 
  where parentA.subid=parentB.id and parentB.id in 
  (select a.id 
      from A a, B b 
      where a.subid=b.id and b.name="***")    
union    //一二层节点求合集 
  (select a.id    //返回第一层父节点 
      from A a, B b 
      where a.subid=b.id and b.name="***") SQL如何进行优化?SQL求父节点的语句执行两次,是否有办法只执行一次?为了效率,希望能用一个SQL进行解决?