sql语句怎么写 啊?

解决方案 »

  1.   

    select a.id from a where a.id not in (select b.id from b)
    union 
    select b.id from b where b.id not in (select a.id from a)
      

  2.   

    select id from a inner join b on a.id<>b.id
    这样写可以吗?
      

  3.   

    同意楼上
    select * from table1 where table1.id not in (select table2.id from table2)
    union 
    select * from table2 where table2.id not in (select table1.id from table1)
      

  4.   

    select * from table1 where table1.id <> (select table2.id from table2)
    union 
    select * from table2 where table2.id <> (select table1.id from table1)这样写为什么出错呢?
      

  5.   

    select * from table1 where table1.id <> (select table2.id from table2)
    union 
    select * from table2 where table2.id <> (select table1.id from table1)
    <>  换成 NOT IN 试试可能跟你的   DBMS  有关
    UNION 有的引擎可能不支持
      

  6.   

    要验证某一个值是否在某一组设置值中,要用运算符 In 的 SQL 语句进行编码,用括号括上待测试的项目列表。
      

  7.   

    in 的效率没有exists高
    select id from table1 where id not exists (select id from table2)
    union
    select id from table2 where id not exists (select id from table1)