如何在MySQL中检查条件时比较多个表?
检查表1
--------------------------
date | Cheque_no
--------------------------
10/10/2015 | 09876543
--------------------------
17/10/2015 | 45678990
--------------------------
付款表2
----------------------------------------
date | Cheque_no | Amount_Paid
----------------------------------------
10/10/2015 | 09876543 | 1000
----------------------------------------
我正在使用以下查询:
select * from Cheque,Payment where Cheque.Cheque_no != Payment .Cheque_no
我期待输出
17/10/2015 | 45678990
答案 0 :(得分:3)
看起来像一个简单的not in
条件可以解决问题:
SELECT *
FROM cheque
WHERE cheque_no NOT IN (SELECT cheque_no FROM payment)