不要用<>啊。可以用 not Exist 来写

解决方案 »

  1.   

    select * from employee  where id in (select id from retire minus select id from adjust)
      

  2.   

    select * from (select a.* from employee a,retire b where a.id = b.id and a.insureid = b.insureid) c where not exists(select 1 from adjust where id = c.id and insureid = c.insureid)
    这样写就不会有你说的那种情况了
      

  3.   

    select distinct a.id ,a.insureid,a.time,b.name
    from retire a,employee b
    where a.id=b.id and a.insureid=b.insureid 
     and (a.id, a.insureid)not in(select id,insureid from adjust where sign<>1) 
     order by a.id但是这样非常慢
      

  4.   

    我写了一个,看看行不行?
    select a.id, a.insureid, a.time, a.name from
    retire a,(select b.id, b.insureid from employee b,
    adjust c where (b.id(+)=c.id) and (b.insureid(+)=c.insureid)
    and (c.sign<>1))tb where (a.id=tb.id) and (a.insureid=tb.insureid)
    order by a.id, a.insureid
      

  5.   

    select distinct a.id,a.insureid,a.time,b.name,c.sign 
    from retire a,employee b
    where a.id=b.id and a.insureid=b.insureid and 
    not exists(select c.id from adjust c where c.id=a.id and c.insureid=a.insureid and c.sign=1 )
      

  6.   

    c.sign应该是没有用处的
    我没有环境,试一下
    select  a.id ,a.insureid,a.time,b.name
    from retire a,employee b
    where a.id=b.id and a.insureid=b.insureid and 
    not exists(select 1 from adjust c where c.id = a.id and c.insureid = a.insureid and c.sign=1)
    order by a.id;
      

  7.   

    washy781231(木木)居然想到一块了,可怜呀,我慢了一步
      

  8.   

    我找到一个快的:
    select distinct a.id ,a.insureid,a.time,b.name
    from retire a,employee b
    where a.id=b.id and a.insureid=b.insureid 
     and (a.id, a.insureid) in(select id,insureid from retire minus select id,insureid from adjust where sign=1) 
     order by a.id
      

  9.   

    to sunnyboy6281
    好象in不如exists快。
    而且你差了个NOT吧