not exist和not in查询结果是否相同?(相同的查询语句)
来源:百度知道 编辑:UC知道 时间:2024/06/30 08:36:12
用途不同,写法不同,一般IN 用于单个字段为条件。而EXISTS 用于多字段为条件。
下列两个结果相同:
SELECT * FROM T1 WHERE T1.ID NOT IN(SELECT T2.ID FROM T2)
SELECT * FROM T1 WHERE NOT EXISTS (SELECT * FROM T2 WHERE T1.ID=T2.ID)
exists如果结果集为空,返回一个false,否则返回true.
而not in的意思是包含这些值.有某些时候(比如查询不包含某些ID值的时候)两种写法差不多,
比如从news中排除news1表中的id值
select * from news n where not exists(select * from news1 id = n.id)
等价于
select * from news n where not in(select id from news1)
USSD Application Not Exist
This fil does not exist
The specified directory does not exist
ET TICKET NUMBER IS NOT EXIST
服务器启动异常!!!Table does not exist.
IIS出现class does not exist这个错误怎么解决
Do you thank there exist extraterrestrials or not
DBConnectionManager.java:8: package org.apace.log4j does not exist
package org.apache.commons.fileupload does not exist
I am not twenty