使用连接查询代替not in

版权声明: https://blog.csdn.net/Dongguabai/article/details/83615873

in函数需要全表扫描,是很耗性能的。

select name,age,address from USER where name not in (select name from CLASSES);

替换为:

select name,age,address from USER left join CLASSES on USER.name=CLASSES.name where CLASSES.name is null;

猜你喜欢

转载自blog.csdn.net/Dongguabai/article/details/83615873
今日推荐