我一个表中有两个字段PID和ID
现在我想用SQL找出ID不等于其它记录PID的记录,应该怎样写?

解决方案 »

  1.   

    select * from table where id<>pid
      

  2.   

    tab_name 是你所说表的名字
    select * from tab_name a where not ID in (select PID from tab_name where ID<>a.ID)
      

  3.   

    select * from table 
    where id not in (select pid from table)
      

  4.   

    我是在ADOQUERY里执行的~~
    参数PID没有默认值~~
      

  5.   

    现在可以执行,但是找不出ID不等于其它记录PID的记录