sql: left join vs. not in

Posted printk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql: left join vs. not in相关的知识,希望对你有一定的参考价值。

select * from product.login_info where username not in (select username from stat.totaluser)

vs.

select a.* from product.login_info as a left join stat.totaluser as b on a.username = b.username where b.username is null

上面2条sql语句的执行结果集是一样的

以上是关于sql: left join vs. not in的主要内容,如果未能解决你的问题,请参考以下文章

NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL: SQL Server

SQL Server-聚焦NOT IN VS NOT EXISTS VS LEFT JOIN...IS NULL性能分析(十八)

查询优化 Not in to Left outer join

MYSQL之not in优化方法:left join

为什么 EXISTS(NOT EXIST) 与 JOIN(LEFT JOIN) 的性能会比 IN(NOT IN) 好

Oracle,用left join 替代 exists ,not exists,in , not in,提高效率