MySQL not in 优化方案
原sql如下:
select id
from A
where
id not in ( select id from B where name = 'zhangsan' );
优化后sql:
select A.id
from A
left join ( select id from B where name = 'zhangsan' ) B
on A.id = B.id
where
B.id is null;
2023-02-23 19:56:00
MySQL not in 优化方案
原sql如下:
select id
from A
where
id not in ( select id from B where name = 'zhangsan' );
优化后sql:
select A.id
from A
left join ( select id from B where name = 'zhangsan' ) B
on A.id = B.id
where
B.id is null;