![](http://e-1.cn/wp-content/uploads/2024/02/frc-576340a359de17e3fcd2b936316c88cf.png)
🌈个人主页: Aileen_0v0
🔥热门专栏: 华为鸿蒙系统学习|计算机网络|数据结构与算法
💫个人格言:“没有罗马,那就自己创造罗马~”
#mermaid-svg-63IIm2s5sIhQfsfy {font-family:”trebuchet ms”,verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-63IIm2s5sIhQfsfy .error-icon{fill:#552222;}#mermaid-svg-63IIm2s5sIhQfsfy .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-63IIm2s5sIhQfsfy .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-63IIm2s5sIhQfsfy .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-63IIm2s5sIhQfsfy .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-63IIm2s5sIhQfsfy .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-63IIm2s5sIhQfsfy .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-63IIm2s5sIhQfsfy .marker{fill:#333333;stroke:#333333;}#mermaid-svg-63IIm2s5sIhQfsfy .marker.cross{stroke:#333333;}#mermaid-svg-63IIm2s5sIhQfsfy svg{font-family:”trebuchet ms”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-63IIm2s5sIhQfsfy .label{font-family:”trebuchet ms”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-63IIm2s5sIhQfsfy .cluster-label text{fill:#333;}#mermaid-svg-63IIm2s5sIhQfsfy .cluster-label span{color:#333;}#mermaid-svg-63IIm2s5sIhQfsfy .label text,#mermaid-svg-63IIm2s5sIhQfsfy span{fill:#333;color:#333;}#mermaid-svg-63IIm2s5sIhQfsfy .node rect,#mermaid-svg-63IIm2s5sIhQfsfy .node circle,#mermaid-svg-63IIm2s5sIhQfsfy .node ellipse,#mermaid-svg-63IIm2s5sIhQfsfy .node polygon,#mermaid-svg-63IIm2s5sIhQfsfy .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-63IIm2s5sIhQfsfy .node .label{text-align:center;}#mermaid-svg-63IIm2s5sIhQfsfy .node.clickable{cursor:pointer;}#mermaid-svg-63IIm2s5sIhQfsfy .arrowheadPath{fill:#333333;}#mermaid-svg-63IIm2s5sIhQfsfy .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-63IIm2s5sIhQfsfy .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-63IIm2s5sIhQfsfy .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-63IIm2s5sIhQfsfy .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-63IIm2s5sIhQfsfy .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-63IIm2s5sIhQfsfy .cluster text{fill:#333;}#mermaid-svg-63IIm2s5sIhQfsfy .cluster span{color:#333;}#mermaid-svg-63IIm2s5sIhQfsfy div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:”trebuchet ms”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-63IIm2s5sIhQfsfy :root{–mermaid-font-family:”trebuchet ms”,verdana,arial,sans-serif;}
a fraction of 一部分.
文章目录
- `SQL`
-
- `DQL条件查询`
- `1.查询年龄等于 88 的员工`
- `2.查询年龄小于 20 的员工信息`
- `3.查询年龄小于等于 20 的员工信息`
- `4.查询没有身份证号的员工信息`
- `5.查询有身份证号的员工信息`
- `6.查询年龄不等于 88 的员工信息`
- `7.查询年龄在15岁(包含) 到 20岁(包含)之间的员工信息`
- `8.查询性别为 女 且年龄小于 25岁的员工信息`
- `9.查询年龄等于18 或 20 或 40 的员工信息`
- `10.查询姓名为两个字的员工信息`
- `11.查询身份证最后一位是 x 的员工信息`
SQL
DQL条件查询
SELECT 字段列表 FROM 表名 WHERE 条件列表 |
比较运算符 |
功能 |
> |
大于 |
>= |
大于等于 |
|
小于 |
|
小于等于 |
= |
等于 |
或 != |
不等于 |
BETWEEN...AND... |
在某个范围内(含最小,最大值) |
IN(...) |
在in之后的列表中的值,多选一 |
LIKE 占位符 |
模糊匹配(_匹配单个字符,%匹配任意个字符) |
IS NULL |
是NULL |
逻辑运算符 |
功能 |
AND 或 && |
并且(多个条件同时成立) |
OR 或 || |
或者(多个条件任意一个成立) |
NOT 或 ! |
非 不是 |
1.查询年龄等于 88 的员工
select * from emp where age = 88;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-1d2ea4287fa5428daaf71cc0a0194fa5.png)
2.查询年龄小于 20 的员工信息
select * from emp where AGE 20;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-4b818386a9f117a029223b998e03b00d.png)
3.查询年龄小于等于 20 的员工信息
select * from emp where AGE 20;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-c7736f2120de0ea0a269e9c75a7d77ae.png)
4.查询没有身份证号的员工信息
select * from emp where IDCARD is null ;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-581397ccd7ef1727135f915031dcd039.png)
5.查询有身份证号的员工信息
select * from emp where IDCARD is not null;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-340ef70ad6e77b310caa8d278c318f09.png)
6.查询年龄不等于 88 的员工信息
select * from emp where age != 88;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-c519b66d67363fec46314594e5f04acd.png)
7.查询年龄在15岁(包含) 到 20岁(包含)之间的员工信息
select * from emp where age between 15 and 20;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-c6bd868e32883760ade8788530e38d96.png)
-
注意:between 之后是最小值,and 之后是最大值。
8.查询性别为 女 且年龄小于 25岁的员工信息
select * from emp where GENDER = '女' and age 25;
![](http://e-1.cn/wp-content/uploads/2024/02/frc-9649d49ee95fd5bbe3ff814845cf0475.png)
9.查询年龄等于18 或 20 或 40 的员工信息
select * from emp where age = 18 || age = 20 || age = 40;
select * from emp where AGE in (18,20,40);
![](http://e-1.cn/wp-content/uploads/2024/02/frc-fdb3db0a3fbe674bb6e97f69844109c4.png)
![](http://e-1.cn/wp-content/uploads/2024/02/frc-c82d046cb8e732455cd35278b0420c6a.png)
10.查询姓名为两个字的员工信息
select * from emp where name like '__';
![](http://e-1.cn/wp-content/uploads/2024/02/frc-1adbca7c2af10c122e39942914a4456b.png)
11.查询身份证最后一位是 x 的员工信息
select * from emp where idcard like '%x';
![](http://e-1.cn/wp-content/uploads/2024/02/frc-565183850d228909f9bd534113ccf4f1.png)
![](http://e-1.cn/wp-content/uploads/2024/02/frc-a3933983f953d71ef6bad48b225f5ec5.gif)
![](http://e-1.cn/wp-content/uploads/2024/02/frc-c44ef5e7a02181480257223362b50271.gif)