求助,关于not exists的
select1,2,3,5
where
not EXISTS (
select
1,2,3)
为啥检索不出数据来,应该怎样弄 --------------------编程问答-------------------- 你这个是什么问题啊,你要把想做的内容好好整理啊 --------------------编程问答--------------------
我就想知道not exists的用法,我上面的写法正确与否 --------------------编程问答-------------------- 你这样肯定没有数据啊,not exits后面的语句是一定存在数据就是1,2,3啊,所以整个sql是没有数据的。你的语法是正确的。 --------------------编程问答--------------------
if not exists (select id from 表 where id=1)
insert into 表 (id) values (1)
按你的想法应该用not in
--------------------编程问答-------------------- SQL中忌用NOT IN,因为NOT IN 效率很低,你的SQL文:
select * from 表 where id not in (1,3,5)
/*
结果:2
4
6
7
...
*/
select
1,2,3,5
where
not EXISTS (
select
1,2,3)
这个sql文的意思是如果 (select 1,2,3)不存在 则检索出1,2,3,4,5,反之如果 (SELECT 1,2,3)存在则select 1,2,3,5不能被检索出数据。 --------------------编程问答-------------------- 关注该问题 --------------------编程问答-------------------- 检索不出来是正常的,因为你的条件是not exists不是exists --------------------编程问答-------------------- 唉。。现在的新人。。 --------------------编程问答-------------------- select * from 主表
where exists (select 1 from 表2 where 表2.id=主表.id)
--------------------编程问答-------------------- select
1,2,3,5
where
not EXISTS (
select
1,2,3)
这句话,哈哈,写得太搞笑了
我开始还没反应过来,等完全看懂的时候,实在忍不住笑了。哈哈哈
这个命令不就是一句废话嘛,哈哈哈。。
1,2,3都不存在,又怎么能返回1,2,3,4,5呢,哈哈哈哈
补充:.NET技术 , VB.NET