当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- duilib 显示内存图片
- Global and Chinese markets for food puffers 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese market of digital fryer 2022-2028: Research Report on technology, participants, trends, market size and share
- 线程的阻塞问题
- Q & A on cloud development cloudbase hot issues of "Huage youyue phase I"
- Event related | reveal how Ti-One's support ability for large-scale events is developed
- [mrctf2020] thousand layer routine
- 屏幕截图推荐—Snipaste
- 光照使用的简单总结
- Étalonnage de la caméra (objectif et principe d'étalonnage)
猜你喜欢
![[WUSTCTF2020]alison_ likes_ jojo](/img/a9/dcc6f524772cd0b8781289cbaef63f.png)
[WUSTCTF2020]alison_ likes_ jojo

鸿蒙os开发三
![[OGeek2019]babyrop](/img/74/5f93dcee9ea5a562a7fba5c17aab76.png)
[OGeek2019]babyrop

Description of module data serial number positioning area code positioning refers to GBK code
![[mrctf2020] thousand layer routine](/img/8e/d7b6e7025b87ea0f43a6123760a113.png)
[mrctf2020] thousand layer routine
![(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 常用函数

How to turn on win11 notebook power saving mode? How to open win11 computer power saving mode

图形技术之管线概念
随机推荐
图形技术之坐标转换
Win11 points how to divide disks? How to divide disks in win11 system?
鸿蒙开发四
阿里云全链路数据治理
Commandes de console communes UE
C escape character
New ways to play web security [6] preventing repeated use of graphic verification codes
How to open the soft keyboard in the computer, and how to open the soft keyboard in win10
Several misunderstandings of VPN
《canvas》之第3章 曲线图形
Global and Chinese market of water massage column 2022-2028: Research Report on technology, participants, trends, market size and share
RDD basic knowledge points
线程的支持
Anaconda 中使用 You Get
Deploy L2TP in VPN (Part 1)
爬虫基础B1——Scrapy(B站学习笔记)
【NILM】非入侵式负荷分解模块nilmtk安装教程
线程的阻塞问题
chrono 使用备注
Shader 常用函数