please___smile的回答就是不在这个范围的意思select id from table where name not exists(select 1 from table where name = 'aaa') 也许你看不懂这个1的意思,不过在使用EXISTS的时候,通常都会使用1,它代表所查询出来的集合,等同于select name。 整个例子的意思是:查询name不等于aaa的所有ID。 不明白再问我,谢谢! agx2004的回答not (不) exists (存在)select * from a where not exists (select 1 from b where b.id = a.id) exists 子查询和 in 子查询的区别之一就在于不直接返回结果集,而是判断结果集条数是否大于零返回true/false,因此 select 1,select 2,select 什么都可以。 上達的回答不存在的意思。就好比你用子查询的时候用的in/not in 同样也可以用exist/not exist select * from table_name1 where id not exist (.............) zhougang39的回答IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SP名]') AND type in (N'P', N'PC'))BEGIN CREATE PROCEDURE [dbo].[SP名] . . END GO 如上面语句中的是说如果系统对象中不存在 名字 = [dbo].[SP名] 的存储过程名,则创建该存储过程。否则不创建。 vivaux的回答not exists 是不存在的意思 |