2015-08-28 233 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 

可以工作的細節。