sql中exists,not exists的用法
来源:互联网 发布:php实现注册登录 编辑:程序博客网 时间:2024/05/01 06:03
exists : 强调的是是否返回结果集,不要求知道返回什么, 比如:
select name from student where sex = ‘m’ and mark exists(select 1 from grade where …) ,只要
exists引导的子句有结果集返回,那么exists这个条件就算成立了,大家注意返回的字段始终为1,如果改成“select 2 from grade where …”,那么返回的字段就是2,这个数字没有意义。所以exists子句不在乎返回什么,而是在乎是不是有结果集返回。
而 exists 与 in 最大的区别在于 in引导的子句只能返回一个字段,比如:
select name from student where sex = ‘m’ and mark in (select 1,2,3 from grade where …)
,in子句返回了三个字段,这是不正确的,exists子句是允许的,但in只允许有一个字段返回,在1,2,3中随便去了两个字段即可。
而not exists 和not in 分别是exists 和 in 的 对立面。
exists (sql 返回结果集为真)
not exists (sql 不返回结果集为真)
0 0
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists、not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- Oracle统计信息
- Mongodb-1
- 不让浏览器缓存js
- iOS 绘制虚线
- HTML DOM Table 对象
- sql中exists,not exists的用法
- GDB调试php扩展错误(Segmentation fault (core dumped))
- Swift快速入门(一)基本类型
- our build settings specify a provisioning profile with the UUID “a1457f8e-1f2f-4f7c-8de1-f3540145b3c
- shell 正则表达式
- Android Studio 那些事| ' ' cannot be applied to '(groovy.lang.Closure)'
- 数据持久化
- js 数组取出最大值最小值的2种方法
- 如何在windows64位的系统上安装,配置mysql?