2015-08-28 234 views
0

我想提出一个count计数这是在TLP但不是在GAL为了这个,我有下面的代码的用户:有什么区别?

select count(*) 
from tlp 
where ((not EXISTS (SELECT mail 
        FROM glob 
        WHERE tlp.email1 = glob.mail) 
     AND tlp.email1 IS NOT NULl) 
     or (not EXISTS (SELECT LOGIN 
         FROM glob 
         WHERE tlp.userid = glob.LOGIN  
         ) 
         and tlp.email1 is null)); 

当我运行此我收到688级的用户,当我想删除用户使用此代码:

Delete from tlp 
    where ((not EXISTS (SELECT mail 
        FROM glob 
        WHERE tlp.email1 = glob.mail ) 
     AND tlp.email1 IS NOT NULl) 
     or (not EXISTS (SELECT Login 
         FROM glob 
         WHERE tlp.userid = glob.login  
         ) 
         and tlp.email1 is null)); 

我有672个删除的行。 我看不出问题

+0

数据刚刚在选择和删除之间改变了吗?这是可重复的吗? –

回答

0

这种方法是简单

select count(*) from 
(
select idField 
from etc -- 
minus 
select idField 
from etc -- these are the records you want to exclude 
) derivedTable 

可以工作的细节。