select t1.* from table1 t1,
(select ParentID from table1 t2 where exists(select t3.ID from table1 t3 where t3.ParentId=t2.ID)) t4
where t1.ID=t4.ParentID;
[Quote=引用 15 楼 kevoo 的回复:]
引用 14 楼 kevoo 的回复:
select t.id,t.name from table t where t.id in(select parrent_id,count(*) as num from table a group by parrent_id where num>2) 这个行不
[Quote=引用 14 楼 kevoo 的回复:]
select t.id,t.name from table t where t.id in(select parrent_id,count(*) as num from table a group by parrent_id where num>2) 这个行不
[/Quote]
select id,name from table_name a
where exists (select id from table_name b
where b.parent_id = a.id
and exists (select id from table_name c where c.parent_id = b.id));