day34 数据库作业

你。 提交于 2019-12-02 19:55:15

数据对表的操作

作业:

  1. 查看岗位是teacher的员工姓名、年龄
    1. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
    2. 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
    3. 查看岗位描述不为NULL的员工信息
    4. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
    5. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
    6. 查看岗位是teacher且名字是jin开头的员工姓名、年薪
1.#查看岗位是teacher的员工姓名、年龄
mysql> select name,age from employee where post = 'teacher';  
+------------+-----+
| name       | age |
+------------+-----+
| alex       |  78 |
| wupeiqi    |  81 |
| yuanhao    |  73 |
| liwenzhou  |  28 |
| jingliyang |  18 |
| jinxin     |  18 |
| 成龙       |  48 |
+------------+-----+


2.#查看岗位是teacher且年龄大于30岁的员工姓名、年龄
mysql> select name,age from employee where post = 'teacher' and age > 30;
+---------+-----+
| name    | age |
+---------+-----+
| alex    |  78 |
| wupeiqi |  81 |
| yuanhao |  73 |
| 成龙    |  48 |
+---------+-----+


3.#查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
mysql> select name,age,salary from employee where post = 'teacher'and salary > 1000 and salary<9000;
+-----------+-----+---------+
| name      | age | salary  |
+-----------+-----+---------+
| wupeiqi   |  81 | 8300.00 |
| yuanhao   |  73 | 3500.00 |
| liwenzhou |  28 | 2100.00 |
+-----------+-----+---------+


4.# 查看岗位描述不为NULL的员工信息
mysql> select * from employee where post_comment is not NULL;
Empty set (0.00 sec)


5.#查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name,age,salary from employee where salary in (10000,9000,30000);
+------------+-----+----------+
| name       | age | salary   |
+------------+-----+----------+
| jingliyang |  18 |  9000.00 |
| jinxin     |  18 | 30000.00 |
| 成龙       |  48 | 10000.00 |
+------------+-----+----------+


6.#查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name,age,salary from employee where salary not in(10000,9000,30000);
+-----------+-----+------------+
| name      | age | salary     |
+-----------+-----+------------+
| egon      |  18 |    7300.33 |
| alex      |  78 | 1000000.31 |
| wupeiqi   |  81 |    8300.00 |
| yuanhao   |  73 |    3500.00 |
| liwenzhou |  28 |    2100.00 |
| 歪歪      |  48 |    3000.13 |
| 丫丫      |  38 |    2000.35 |
| 丁丁      |  18 |    1000.37 |
| 星星      |  18 |    3000.29 |
| 格格      |  28 |    4000.33 |
| 张野      |  28 |   10000.13 |
| 程咬金    |  18 |   20000.00 |
| 程咬银    |  18 |   19000.00 |
| 程咬铜    |  18 |   18000.00 |
| 程咬铁    |  18 |   17000.00 |
+-----------+-----+------------+


7.# 查看岗位是teacher且名字是jin开头的员工姓名、年薪
mysql> select name,salary from employee where name like 'jin%';
+------------+----------+
| name       | salary   |
+------------+----------+
| jingliyang |  9000.00 |
| jinxin     | 30000.00 |
+------------+----------+
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!