一步一步走下去……

关于内嵌的sql子句(exists,some,any,all)

上一篇 / 下一篇  2009-05-14 17:10:25 / 天气: 晴朗 / 心情: 平静 / 个人分类:数据库

 

//查询出表1中不存在表2中的数据

select * from table1 where user_id not in (select user_id from table2);

 

//若子查询查询出结果返回true,则显示主查询结果,若为false则不出结果

select * from table1 where EXISTS (select * from table2);

 

//=anyin 操作类似,但不一样,any可以执行>,<操作,而in不可以

select * from table1 where user_id = any (select user_id from table2 );

 

//只要左边内容和右边内容中任何一个不一样

select * from table1 where user_id != some (select user_id from table2 );

 

//只有当左边内容不存在于右边时才返回true,和not in类似

select * from table1 where user_id <> all (select user_id from table2 );


TAG:

kopac的个人空间 引用 删除 kopac   /   2011-10-10 15:49:55
-3
 

评分:0

我来说两句

日历

« 2024-04-17  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 5381
  • 日志数: 9
  • 建立时间: 2009-05-14
  • 更新时间: 2009-07-28

RSS订阅

Open Toolbar