子查询之运算符

IN 

   select * from A where ID IN select  ID from B

 

NOT IN 格式与IN相同(只是取反)

 

 

逻辑运算符

EXISTS 

  if EXISTS( select * from A)

  BEGIN  

    print ' 没有记录 '

  END

 检查查询的结果集是否存在(exists)值如果没有值,则返回false

 

ALL

select * from A where Id >ALL(select ID from B  )

 

ANY/SOME 

早期的SQL允许使用ANY,后来的版本为了使其与英语的ANY相区分引入了SOME,同时也保留了ANY关键字

select * from A where ID>ANY(select from select ID from B)

在=ANY时“=ANY”和“IN”等效

 

posted on 2013-05-17 10:11  张张开  阅读(217)  评论(0)    收藏  举报

导航