SQL关于IN和EXISTS的区别?请问2者到底有什么区别啊?select MC001 from BOMMC WHERE MC001 NOT IN (SELECT MD001 FROM BOMMD)和select MC001 from BOMMC WHERE MC001 NOT EXISTS (SELECT MD001 FROM BOMMD)2个IN查出来是80,而EXISTS查出来是
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 20:31:06
SQL关于IN和EXISTS的区别?请问2者到底有什么区别啊?select MC001 from BOMMC WHERE MC001 NOT IN (SELECT MD001 FROM BOMMD)和select MC001 from BOMMC WHERE MC001 NOT EXISTS (SELECT MD001 FROM BOMMD)2个IN查出来是80,而EXISTS查出来是
SQL关于IN和EXISTS的区别?
请问2者到底有什么区别啊?
select MC001 from BOMMC WHERE MC001 NOT IN (SELECT MD001 FROM BOMMD)
和
select MC001 from BOMMC WHERE MC001 NOT EXISTS (SELECT MD001 FROM BOMMD)
2个IN查出来是80,而EXISTS查出来是没有结果,请问下2者有什么区别?
什么情况下使用
不是很明白,能把1、2、3、4、5当做1个表里面的值,给我举下例子啊?
SQL关于IN和EXISTS的区别?请问2者到底有什么区别啊?select MC001 from BOMMC WHERE MC001 NOT IN (SELECT MD001 FROM BOMMD)和select MC001 from BOMMC WHERE MC001 NOT EXISTS (SELECT MD001 FROM BOMMD)2个IN查出来是80,而EXISTS查出来是
IN 其实与等于相似,比如in(1,2) 就是 = 1 or = 2的一种简单写法,所以一般在元素少的时候使用IN,如果多的话就用exists
exists的用法跟in不一样,一般都需要和子表进行关联,而且关联时,需要用索引,这样就可以加快速度.
你的SQL语句用NOT EXISTS可以写成
select MC001 from BOMMC WHERE NOT EXISTS (SELECT MD001 FROM BOMMD where BOMMC.MC001 = BOMMD.MD001)