When we use in and not in, it will take a long time to get the results. because it scans all the records of the table. we can use left join instead of in or not in like the following:

1. select * from table1 where tabel1.name not in (select name from table2)    is equals to
   select a.* from table1 a left join table2 b on a.name = b.name where b.name is null.

2. select * from table1 where tabel1.name in (select name from table2)    is equals to
   select a.* from table1 a left join table2 b on a.name = b.name where b.name is not null.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2018-07-05
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案