select * from tablea where name!= (select name from tableb) and id>3
                                  -------------------------
一列到多列会产生错误~
改为:
select * from tablea where name not in (select name from tableb) and id>3

解决方案 »

  1.   

    同意!不过,当数据量比较大的时候,not in 会相对慢一些,你可以试试这个:
    select * from taba a where a.name not exits(select b.name from tabb b where a.name = b.name) and id > 3;
      

  2.   

    不好意思,exits 改为exists
      

  3.   

    UP!UP!我也来说另外一种办法:就是使用ORACLE SQL操作的集合运算, 采用 Minus操作就可以了 假设我想要出TABA中不在TABB中的NAME,可以这样写:SELECT NAME FROM TABA WHERE A.NAME MINUS (SELECT NAME FROM TABB) AND TABA.ID>3;呵呵,这样和not exists也是一样的. 其他的集合操作还有: UNION[ALL], INTERSECT.