当前位置:网站首页>Oracle-高级SQL限定查询
Oracle-高级SQL限定查询
2022-06-24 06:46:00 【旷世奇才李先生】
一个人必须不停地写作,才能不被茫茫人海淹没
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

关系运算:>、=、<、>=、<=、!=、<>
范围运算:between…and
空判断:is null、is not null
IN判断:in、not in
模糊查询:like、not like
逻辑运算:and(与)、or(或)、not(非)
一、关系运算符
1、查询年龄低于20的学生
select * from student where age < 20;
2、查询所有的男同学
select * from student where sex='男';
3、查询不是男同学的所有学生
以下两种都可以
select * from student where sex != '男';
select * from student where sex <> '男';
二、逻辑运算符
and、or
1、查询不是男生但是年龄小于20的同学
select * from student where sex != '男' and age < 20;
2、查询是女同学或者年龄大于20的同学
select * from student where sex = '女' or age > 20;
3、查询年龄小于20的同学
以下两种都可以
select * from student where age < 20;
select * from student where age not >= 20;
三、范围运算
1、查询年龄在10岁到20岁之间的同学
以下两种都可以,但是between是一个运算符,而另外一个是一个关系运算符>=加上一个逻辑运算符and,所以between的效率要高一些。
select * from student where age between 10 and 20;
select * from student where age >= 10 and age <= 20;
2、查询在1998年9月出生的学生
select * from student where birthday between '01-9月-98' and '30-9月-1998';
四、空判断
1、查询姓名不为空的同学
select * from student where name is not null;
五、IN操作符
1、查询姓名为张三和李四的同学
select * from student where name in ('张三','李四');
2、查询姓名为张三和空的同学
select * from student where name in ('张三',null);
3、查询姓名不为张三和空的同学
select * from student where name not in ('张三',null);
这里需要注意,当not in中有null时,是查询不出任何结果的。
六、模糊查询
“_”:匹配任意的一位符号。
“%”:匹配任意个符号,可以是0、1、2、多个符号。
1、查询姓李的同学
select * from student where name like '李%';
2、查询姓李的同学,并且名字只有两个字
select * from student where name like '李_';
3、查询名字中包含“帅”字的同学
select * from student where name like '%帅%';
七、查询排序
order by [排序规则]
默认和asc是正序排序
desc是倒序排序
1、查询所有同学,并且按照年龄由小到大排序
select * from student order by age;
2、查询所有同学,并且按照年龄由大到小排序
select * from student order by age desc;
3、查询所有同学,并且按照年龄由大到小排序,如果年龄相等则按照学号由小到大排序
select * from student order by age desc,sno;
4、查询所有同学,并且按照年龄由大到小排序,如果年龄相等则按照学号大到小排序
select * from student order by age desc,sno desc;
八、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
猜你喜欢

MaxCompute远程连接,上传、下载数据文件操作

Win10 build webservice
![[frame rate doubling] development and implementation of FPGA based video frame rate doubling system Verilog](/img/38/92486c92557e6e5a10a362eb2b7bdf.png)
[frame rate doubling] development and implementation of FPGA based video frame rate doubling system Verilog
![(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]](/img/33/d601a6f92b1b73798dceb027263223.png)
(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]

Shader 常用函数

鸿蒙os开发三

How to turn on win11 notebook power saving mode? How to open win11 computer power saving mode
╯︵ ┻━┻](/img/26/6986a8ae6c00eb2431a082dc0ff978.png)
[DDCTF2018](╯°□°)╯︵ ┻━┻

屏幕截图推荐—Snipaste

希尔伯特-黄变换
随机推荐
Detailed explanation of C language compilation, link and operation
Dichotomous special training
LeetCode 207:课程表(拓扑排序判断是否成环)
Commandes de console communes UE
Global and Chinese market of offshore furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
日期、时间库使用备注
《canvas》之第1章 canvas概述
Black box and white box models for interpretable AI
图形技术之坐标转换
What should I pay attention to after the live broadcast system source code is set up?
Camera calibration (calibration purpose and principle)
常见的数组封装
简单的折射效果
Selector (>, ~, +, [])
Event related | reveal how Ti-One's support ability for large-scale events is developed
tuple(元组)备注
【MySQL 使用秘籍】克隆数据表、保存查询数据至数据表以及创建临时表
atguigu----16-自定义指令
[vulhub shooting range]] ZABBIX SQL injection (cve-2016-10134) vulnerability recurrence
duilib 显示内存图片