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 );

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值