本文主要是介绍SQL语句查处两表中,A表中的不再B表中存在的数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
bill_price表[数据多]
| goods_name | goods_standard | goods_maerial | goods_factoy | city_name |
sale_market表[数据多]
| goods_name | goods_standard | goods_maerial | goods_factoy | city_name |
Q:查出bill_price表中数据不再[sale_market]表中的数据 ;目的:将查处的数据写入[sale_market];
[当建立了5字段索引后,查询效率提高很多]
语句1:
select count(*) from bill_price where bill_price_id not in(select b.bill_price_id from bill_price as b, sale_market as s where s.goods_name = b.goods_name and s.goods_material = b.g;oods_material and s.goods_standard = b.goods_standard and s.goods_factory = b.goods_factory and s.city_name =b.city_name );
语句2:
select count(*) from bill_price b where not exists (select 1 from sale_market s where s.goods_name = b.goods_name and s.goods_material = b.goods_material and s.goods_standard = b.goods_standard and s.goods_factory = b.goods_factory and s.city_name =b.city_name );
这篇关于SQL语句查处两表中,A表中的不再B表中存在的数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!