Reputation: 45
I want to return all records that do not exist in an union of two other tables but when i try to enclose the result of the union the workbench returns a syntax error. What i'm doing wrong?
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%')
)
;
Upvotes: 0
Views: 30
Reputation: 37473
You can try below -
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)
Upvotes: 1