I eat rice
2021-04-02T15:09:13+00:00
表a
isbn字段 和其他字段若干 几十万条记录
表b
isbn字段 和 其他字段若干 几千条记录
想用表b的isbn与表a的isbn对比,并把表b里不与表a重复的isbn和其他其他字段生成表c 最后输出
这种sql语句怎么写?
[quote][tid=26209543]Topic[/tid] Post by [uid=41301250]金不换猫不理[/uid] (2021-04-05 23:18):
表a
isbn字段 和其他字段若干 几十万条记录
表b
isbn字段 和 其他字段若干 几千条记录
想用表b的isbn与表a的isbn对比,并把表b里不与表a重复的isbn和其他其他字段生成表c 最后输出
这种sql语句怎么写?[/quote]b表left join a表,去a. Isbn is null
[quote][pid=505666335,26209543,1]Reply[/pid] Post by [uid=40555654]lsfcx1992[/uid] (2021-04-05 23:23):
b表left join a表,去a. Isbn is null[/quote]还是not in简单
几十万条数据的话,估计需要中间表,原表直接执行sql语句性能损失很大
不就是not exists吗
什么不重复,就是存在表b不存在表a吧……
select *from b where not exists (select 1from awhere a.×
=b.×)
select * from b where b.isbn not in(select a.isbn from a)
大兄弟你这基础太差了点。
子查询条数大的用not exists
几千条就 not in
select * from a where a.xx not in (select b.xx from b where b.xxxxxxxxxx)
Reply to [pid=505667237,26209543,1]Reply[/pid] Post by [uid=25594519]蓝色的眼镜[/uid] (2021-04-05 23:28)
感谢!我不是基础差,是根本没基础。被逼无奈,赶紧学。