# 书写顺序(英语语法)
select id,name from emp where id > 3;
# 执行顺序
from
where
select
# 执行顺序和书写顺序不一致,就按照书写顺序写 sql
select * 先用 * 来占位
之后补全后面的 sql 语句
最后将 * 号替换成想要的具体字符
where过滤
# 作用:对整体数据的一个筛选操作(可以理解为 python 中的 if)
# 查询 id 大于等于 3 小于等于 6 的数据
select id,name,age from emp where id >= 3 and id <= 6;
select id,name,age from emp where id between 3 and 6; # 两种等价
+----+-------+-----+
| id | name | age |
+----+-------+-----+
| 3 | kevin | 81 |
| 4 | tony | 73 |
| 5 | owen | 28 |
| 6 | jack | 18 |
+----+-------+-----+
# 查询薪资是 20000 或 18000 或 17000 的数据
select id, name, salary from emp where salary = 20000 or salary = 18000 or salary = 17000;
select id, name, salary from emp where salary in (20000, 18000, 17000);
+----+-----------+----------+
| id | name | salary |
+----+-----------+----------+
| 15 | 程咬金 | 20000.00 |
| 17 | 程咬铜 | 18000.00 |
+----+-----------+----------+
# 查询员工姓名中包含字母 o 的员工的姓名和薪资
select name, salary from emp where name like "%o%";
+-------+------------+
| name | sa