A,B两记录集
怎么写一条SQL语句让A中有。B中没有记录显示出来

解决方案 »

  1.   

    select A.* from A,B where A.ID=B.ID and B.id is not null
    试试这样的语句呢
      

  2.   

    有,没有怎么判断?是指关键字一样吗? 还是除关键字所有字段都一样?还是所有字段都一样?如果是指关键字一样的,试试下面的
    ID是关键字select * from a where id not in (select id from b)如果是其它情况,我一会再来看看。。呵
      

  3.   

    是这个意思
    A表
     id , 类型,字段1,字段2
    B表
     id,  类型, 字段1,字段2
    记录如下
    A表
     1,   11      12, 12
     2,   11      13, 13
     3,   22      14, 24
    B表
     1,   11      21 ,21
     3,   22,     14,24
    是想显示记录编号相同,但A表字段1和B表字段2值不同想的记录,并且如果记录在A表中有,B表中没有的也要显示出来
      

  4.   

    SELECT a.* from a left join b on a.id=b.id where a.字段1<>b.字段1 or a.字段2<>b.字段2
      

  5.   

    select a.id
    from a left join b on a.id = b.id 
    where a.字段1 <> b.字段2