当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- [understanding of opportunity -29]: Guiguzi - internal dialogue - five levels of communication with superiors
- [从零开始学习FPGA编程-42]:视野篇 - 后摩尔时代”芯片设计的技术演进-1-现状
- Tidb operator source code reading (IV) control cycle of components
- [OGeek2019]babyrop
- How to select a third-party software testing company? 2022 ranking of domestic software testing institutions
- 线程注意事项
- 相机标定(标定目的、原理)
- 2.1.1 QML grammar foundation I
- Global and Chinese market of anion sanitary napkins 2022-2028: Research Report on technology, participants, trends, market size and share
- UE常用控制台命令
猜你喜欢

阿里云全链路数据治理

LeetCode 207:课程表(拓扑排序判断是否成环)

Combine with (& &) logic or (||), dynamic binding and ternary operation
![buuctf misc [UTCTF2020]docx](/img/e4/e160f704d6aa754e85056840e14bd2.png)
buuctf misc [UTCTF2020]docx
![[GUET-CTF2019]zips](/img/79/22ff5d4a3cdc3fa9e0957ccc9bad4b.png)
[GUET-CTF2019]zips

屏幕截图推荐—Snipaste

When MFC uses the console, the project path cannot have spaces or Chinese, otherwise an error will be reported. Lnk1342 fails to save the backup copy of the binary file to be edited, etc

Win11 points how to divide disks? How to divide disks in win11 system?

Dichotomous special training

How to turn on win11 notebook power saving mode? How to open win11 computer power saving mode
随机推荐
Accessing user interface settings using systemparametersinfo
MSSQL high permission injection write horse to Chinese path
Shell script for MySQL real-time synchronization of binlog
Spark stage and shuffle for daily data processing
相機標定(標定目的、原理)
Actual target shooting - skillfully use SMB to take down the off-line host
exness:鲍威尔坚持抗通胀承诺,指出衰退是可能的
How to connect the Bluetooth headset to the computer and how to connect the win10 computer to the Bluetooth headset
Reppoints: Microsoft skillfully uses deformation convolution to generate point sets for target detection, full of creativity | iccv 2019
duilib 显示内存图片
Global and Chinese market of inline drip irrigation 2022-2028: Research Report on technology, participants, trends, market size and share
Étalonnage de la caméra (objectif et principe d'étalonnage)
【MySQL 使用秘籍】克隆数据表、保存查询数据至数据表以及创建临时表
【008】表格数据逐行筛选,跳出for循环及跳过本次循环思路_#VBA
阿里云全链路数据治理
What should I pay attention to after the live broadcast system source code is set up?
[MySQL usage Script] clone data tables, save query data to data tables, and create temporary tables
Reconfiguration of nebula integration testing framework based on BDD theory (Part 2)
Deploy L2TP in VPN (medium)
How to realize high stability and high concurrency of live video streaming transmission and viewing?