MySQL不联盟 [英] Mysql not union
本文介绍了MySQL不联盟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有2张桌子.
表1:
ID CUST_NO
1 51555
2 51556
3 51111
4 44444
5 54878
6 13548
和表2:
ID CUST_NO
1 51555
2 51556
3 31333
4 97948
5 65488
6 14648
. .....
我知道我可以使用联合来获取出现在两个表中的CUST_NO.但是,我需要获取出现在表1中而不是表2中的CUST_NO的列表.
I know I can use union to get the CUST_NO's that appear in both tables. However, I need to get the list of CUST_NO's that appear in table 1, but not in table 2.
因此,结果应该是
51111
44444
54878
13548
我敢打赌这真的很容易,但是我现在不能动弹头,有什么想法吗?
I bet this is really easy but I just can't use my head right now, any thoughts?
推荐答案
select t1.CUST_NO
from Table1 t1
left outer join Table2 t2 on t1.CUST_NO = t2.CUST_NO
where t2.CUST_NO is null
这篇关于MySQL不联盟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文