高级查询
来源:互联网 发布:联通冰激凌套餐 知乎 编辑:程序博客网 时间:2024/05/06 16:03
一.子查询:
1简单子查询语法:
select * from 表名 where 列 运算符 (子查询)
例:
select name from student where id =(select id from result where score=60)--查询分数等于60的一个学生
2.in子查询:
in子查询可以反回多个记录
语法:
select * from 表名 where 列 in (子查询)
例:
select name from student where id in(select id from result where score>60)--查询分数大于60的所有学生
3.not in子查询
not in子查询可以查询到没有达成条件的结果
语法:
select * from 表名 where 列 not in (子查询)
例:
select name from student where id not in(select id from result where score>60)--查询分数没有大于60的所有学生
4.exists子查询:
exists关键字可以检测数据是否存在.一般用于if语句的存在检测.
语法:
if exists(子查询)
例:
if exists(select * from result where subjectno=(select subjectno from subject where subjectname='Java'))
5.not exists子查询:
exists和in一样,添加not关键字可以实现取反操作,not exists表示不存在.
例:
if not exists(select * from result where subjectno=(select subjectno from subject where subjectname='Java'))
- 高级查询
- 高级查询
- 高级查询
- 高级查询
- 高级查询
- 高级查询
- 高级查询
- 高级查询
- 高级查询
- Oracle高级技巧,高级查询
- mybatis高级查询-一对一查询
- Oracle 查询及高级查询
- SQL高级查询
- Oracle高级查询
- lucene.....高级查询
- SQL高级查询相关
- sql高级语句查询
- SQL高级查询技巧
- mybatis高级查询-一对一查询
- neuraltalk2将eval.lua改成一个服务 不断的增量分析图像
- 算法课第2周第2题——241. Different Ways to Add Parentheses
- intellij live Templates 设置
- 【数组】Leetcode编程题解:289. Game of Life Add to List
- 高级查询
- 算法基础之冒泡排序
- android逆向工具
- bzoj 4180: 字符串计数 (后缀自动机+矩阵乘法)
- IOS 3D Touch功能分析
- golang语言并发与并行——goroutine和channel的详细理解(二)
- next主题如何添加动态背景
- codevs 2744 养鱼喂妹纸
- HDU1081