因为 not in不走索引,所以不在不得已情况下,就不要使用not in

下面使用 join 来替代not in 做查询

select ID from A where ID not in (select ID from B)

替换为

select A.ID from A left join B on A.ID=B.ID and B.ID is null
或者:
select A.ID from A left join B on A.ID=B.ID where B.ID is null

相关文章:

  • 2022-12-23
  • 1970-01-01
  • 2022-12-23
  • 2021-07-30
  • 2021-12-17
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案