表格1查询:select mbl from passinfo where orderid='443140' and toolsindex='60'
表格2查询:select mbl from indata where orderid='443140'
表格1查询显示列:mbl数量有2621个
表格2查询显示列:mbl数量有16608个
对比表1和表格2,只显示表格1未包含的mbl个数13987。
select mbl from passinfo where orderid='443140' and toolsindex!='60'
或者
select mbl from indata where orderid='443140' and mbl not in(
select mbl from passinfo where orderid='443140' and toolsindex='60'
)
表格2语句
except
表格1语句
最简单的方式,用except
select mbl from indata where orderid='443140'
except
select mbl from passinfo where orderid='443140' and toolsindex='60'
或者用exists
select mbl from indata a where orderid='443140' and
not exists (select 1 from passinfo b where b.orderid='443140' and b.toolsindex='60' and a.mbl=b.mbl)
或者用 in,上面有人贴了代码了
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!只要第一条语句,把条件改为!=60就可以了
select mbl from passinfo where orderid='443140' and toolsindex != '60'