select * from New_tr
where **(PeopleSoftID,** TransDate,TransactionCode) not in
(select PeopleSoftID,TransDate,TransactionCode from Old_tr)
它显示以下错误错误:
An expression of non-boolean type specified in a context where a condition is expected, near ','.
可能导致错误的原因是什么?
答案 0 :(得分:1)
我相信根据您使用MS SQL Server的错误消息。 MS SQL Server不支持IN语句中的多个列。您可以轻松地将其重写为左连接,其中where为null以解决您的问题
SELECT * FROM New_tr
LEFT JOIN Old_tr ON (Old_tr.PeopleSoftID = New_tr.PeopleSoftID
and Old_tr.TransDate = New_tr.TransDate
and Old_tr.TransactionCode = New_tr.TransactionCode)
where Old_tr.PeopleSoftID is null