我想返回其他两个表的联合中不存在的所有记录,但是当我尝试封装联合的结果时,工作台将返回语法错误。我做错了什么?

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%')
)
;

最佳答案

您可以在下面尝试-

    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)

关于mysql - 如何从一个表中选择所有不存在于mysql中两个其他表的并集的所有记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55038084/

10-10 12:56