Sql 有什么区别?
我想计算tlp中但不在gal中的用户数。为此,我有下一个代码:Sql 有什么区别?,sql,oracle-sqldeveloper,Sql,Oracle Sqldeveloper,我想计算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
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行。
我看不出问题所在这种方法更简单
select count(*) from
(
select idField
from etc --
minus
select idField
from etc -- these are the records you want to exclude
) derivedTable
您可以计算出详细信息。数据是否在选择和删除之间发生了更改?这是可复制的吗?