我想返回两个其他表的并集中不存在的所有记录,但是当我尝试封装并集的结果时,工作台将返回语法错误。我在做什么错了?
SELECT TransactionID
from transactions
where transactionid not in
(
(select distinct Transactionid
from transactionsdebits
where accountid like '81%')
union
(select distinct TransactionID
from transactionscredits
where accountid like '81%')
)
;
答案 0 :(得分:1)
您可以在下面尝试-
SELECT TransactionID
from transactions
where transactionid not in ( select transactionid from
(
select distinct Transactionid
from transactionsdebits
where accountid like '81%'
union
select distinct TransactionID
from transactionscredits
where accountid like '81%'
)
A)