应该是在关系数据库中建立的反映树状结构的表吧?我有一个比较笨的办法,
SELECT COUNT(*) FROM table_x....,后面是递归查询语句,若count(*)大于1,则表明是非叶子节点。

解决方案 »

  1.   

    不清楚你的表结构,参考一下吧:
    ID:接点
    PID:父节点SQL> select * from testtree;ID         PID
    ---------- ----------
    1          0
    2          0
    3          1
    4          1SQL> select * from testtree a
      2  where not exists(select 'x' from testtree connect by prior id = pid start with pid = a.id);ID         PID
    ---------- ----------
    2          0
    3          1
    4          1
      

  2.   

    楼上的你的sql 无法执行亚
      

  3.   

    把你的表结构贴出来看看。如果你是 id,parent_id形式的可以用我上面的,我已经在SQL PLUS测试通过了!上面是贴的测试结果,再整理一下:
    select * from testtree a
    where not exists (select 'x' from testtree 
                      connect by prior id = pid
                      start with pid = a.id)如果你是id,child_id的话,可以把叶子节点的child_id 设成null,那直接就可以来判断的啊