不知道这个为什么不对select * from table where id in (select parentid from table where parentid !=0)

解决方案 »

  1.   

    mysql 不支持子查询的,应该这样
    select a1.* from a a1,a a2 where a1.parentid=0 and a2.parentid<>0 and a2.parentid=a1.id
      

  2.   

    分都给我行了,呵呵!问题在表的别名上面,给括号中的表取个别名就行了,如:select * from table where id in (select parentid from table a where parentid !=0)
      

  3.   

    汗!刚才喝水的时候突然意识的可能有问题,试了一下果然不对,SORRY!同意二楼,可能是版本较低不支持子查询,mysql4.1以上支持子查询。
      

  4.   

    谢谢楼上的兄弟们,问题已经解决,谢谢!select * from table as a, table as b where a.id=b.parentid and a.parentid=0;给分结题!