一步一步走下去……
关于内嵌的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);
//=any和in 操作类似,但不一样,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: