当前位置: 代码迷 >> Sql Server >> not exists,该怎么处理
  详细解决方案

not exists,该怎么处理

热度:48   发布时间:2016-04-27 21:08:51.0
not exists
select   *   from   c1   as   t   where   not   exists((
select   count(*)   from   c1   where   t.score> c1.score)   > 2)
为什么出错?能这样使用吗?

------解决方案--------------------
select * from c1 as t where --not exists
((select count(*) from c1 where t.score> c1.score)> 2)
not exists用法不正确
------解决方案--------------------
--try
select * from c1 as t where (select count(*) from c1 where t.score> c1.score)> 2

------解决方案--------------------
不要用not exists
例如:
if exists(select 1 from sysobjects where id=object_id( 'tablename '))
drop table tablename

也可以写成:
if (select count(1) from tablename )> 0
drop table tablename
  相关解决方案