摆渡一下
start with ...connect by ...

解决方案 »

  1.   

    楼上,我的是SQL的啊...而且是ACCESS..能不能用你这个?
      

  2.   

    select products.Pcode,D.Name1,D.subdepart1,d.subdepart2
    from products 
    left join
    (select A.DID,A.Name1,B.DID as subid1,B.Name1 as subdepart1,c.DID as subid2,C.Name1 as subdepart2 
    from depart A
    left join depart B
    on  B.ParentID = A.DID 
    left join depart C
    on C.ParentID = B.DID) as D
    on products.departID in(D.DID,D.subid1,D.subid2)
    where D.name1 = '部门名称'  --- ‘部门名称' 为你要查询的部门以上SQL语句测试通过,楼主试一下~~~ 
      

  3.   

    试试这个
    select * from products a where not exists (select * from products where parentid=t.did)
      

  4.   

    不好意思写错了,应该是
    select * from products t where not exists (select * from products where parentid=t.did)