当前位置: 代码迷 >> J2SE >> sql语句优化解决办法
  详细解决方案

sql语句优化解决办法

热度:86   发布时间:2016-04-23 23:03:16.0
sql语句优化
我有这样一条sql语句:
 select t.* from t_cms_category t where t.id not in (select  t2.parentid from t_cms_category t2);

表中的数据是:
SQL> select * from t_cms_category;
 
        ID NAME                                                                               PARENTID
---------- -------------------------------------------- ----------
     10001 test1                                                                                    -1
     10002 test2                                                                                    -1
     10003 test1.1                                                                               10001
     10004 test4                                                                                    -1
     10005 test2.1                                                                               10002

我希望得到的是1003 1004 1005 我上面写的sql能查出来 可是怎么优化下这条sql呢 求大神指点下

------解决方案--------------------
 select t.* from t_cms_category t where t.id not in (select  t2.parentid from t_cms_category t2);
  相关解决方案