select *
from table1,tabel2
where table1.a<>table2.b

解决方案 »

  1.   

    select *
    from table1 t1,tabel2 t2
    where t1.a<>t2.b
      

  2.   

    create table ll_a(
    a varchar2(10)
    )create table ll_b
    (
    b  VARCHAR2(20)
    )begin
    insert into ll_a values('aa');
    insert into ll_a values('bb');
    insert into ll_a values('cc');insert into ll_b values('aa');
    insert into ll_b values('bb');
    insert into ll_b values('dd');
    end;select *
    from ll_a  ,ll_b
    where ll_a.a<>ll_b.b--结果
    bb aa
    cc aa
    aa bb
    cc bb
    aa dd
    bb dd
    cc dd
    ----结果不对么
    要么你给出数据
    给出结果
    看你上面的描述,我觉得我的结果没问题啊    
      

  3.   

    icedut(冰)   兄弟,你的第二次回复和第一次有什么区别。?。两个字段本来就在两个不同的表里。。   呵呵。不过还是感谢关注。。
      

  4.   

    sxiong() 我的回复就是说我没有明白你的意思
    我的回复中,有数据
    如果是我列的数据
    结果是什么样呢我不知道你的表中数据什么样
    你要的结果又是什么样别人很难理解你的意思
      

  5.   

    有两个表table1,table2  里面分别一个字段有a ,b  如何列出满足条件table1.a<>table2.b 的记录 如何写sql语句。。这两表没有其他的关联条件--如果
    你给出数据
    给出结果
    别人理解会容易些
    而且和你的想法不会有太大出入
      

  6.   

    是这样的。。table1里有字段a 里面有数据
    2
    3
    4
    table2里有字段b  有数据
    3
    4
    56
    7
    对于上述几条数据(实际库中好多),就是过虑出来table1.a=4的记录来   不知道  我描述清楚了没有
      

  7.   

    select *
    from table1
    where table1.a not in (select table2.b from table2)
    union all
    select *
    from table2
    where table2.b not in (select table1.a from table1)
      

  8.   

    --
    为什么是4
    4在两个表中都有
    而且3也有
    为什么不一起出来
    --是这样的。。table1里有字段a 里面有数据
    2
    3
    4
    table2里有字段b  有数据
    3
    4
    56
    7
    对于上述几条数据(实际库中好多),就是过虑出来table1.a=4的记录来   不知道  我描述清楚了没有
      

  9.   

    select a from a
    minus
    select b from b
      

  10.   

    --建立测试表1
    create table test1
    (id number);
    --建立测试表1
    create table test2
    (id number);
    --插入测试数据
    insert into test1 values(1);
    insert into test1 values(2);
    insert into test1 values(3);
    insert into test1 values(4);
    --插入测试数据
    insert into test2 values(1);
    insert into test2 values(2);
    insert into test2 values(5);
    insert into test2 values(6);
    --执行语句,察看结果
    select id
    from test1
    union
    select id
    from test2
    minus
    select a.id
    from test1 a,test2 b
    where a.id = b.id;        ID
    ----------
             3
             4
             5
             6