mysql NOT IN和NOT EXIST不一样吗? [英] Mysql NOT IN and NOT EXIST the same?

查看:148
本文介绍了mysql NOT IN和NOT EXIST不一样吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时在我的sql查询中互换使用NOT INNOT EXIST,并且两者都产生相同的结果. NOT EXIST背后的逻辑与NOT IN相同吗?因为我认为NOT IN ...(在子查询中被评估为或")等于NOT EXIST(也被评估为或")?还是我想念什么?

I sometimes interchanged the use of NOT IN and NOT EXIST in my sql queries and both yield the same result. Is the logic behind the NOT EXIST the same as NOT IN? Because I think that NOT IN... (is being evaluated as "OR" inside the subqueries) is equal to NOT EXIST (which is also evaluated as "OR")? Or am i missing something?

推荐答案

您可能会对本文感兴趣:

This article may be of interest to you:

简而言之,NOT INNOT EXISTS在两个处理子查询返回的NULL值的方式上稍有不同.

In a nutshell, NOT IN is slightly different from NOT EXISTS in the way the two handle NULL values returned by the subquery.

如果没有NULL值,它们都对NESTED LOOP ANTI JOIN执行某种操作,但是NOT IN效率更高.

If there are no NULL values, they both perform a kind on NESTED LOOP ANTI JOIN, but NOT IN is a little bit more efficient.

这篇关于mysql NOT IN和NOT EXIST不一样吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆