day34 作业

*爱你&永不变心* 提交于 2019-12-02 19:31:01

作业:

  1. 查看岗位是teacher的员工姓名、年龄
  2. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
  3. 查看岗位是teacher且薪资在9000-10000范围内的员工姓名、年龄、薪资
  4. 查看岗位描述不为NULL的员工信息
  5. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
  6. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
  7. 查看岗位是teacher且名字是jin开头的员工姓名、年薪
mysql> select * from homework;
+----+------+-----+--------+---------+
| id | name | age | salary | job     |
+----+------+-----+--------+---------+
|  1 | tbw  |  22 |   5000 | winder  |
|  2 | nick |  28 |  10000 | teacher |
|  3 | egon |  35 |  80000 | teacher |
|  4 | echo |  12 | 150000 | teacher |
|  5 | tank |  25 |   9500 | teacher |
|  6 | jinx |  17 |  66666 | teacher |
|  7 | crud |  55 |   9000 | teacher |
+----+------+-----+--------+---------+
7 rows in set (0.00 sec)
------------------------------------------------------------
# 1.查看岗位是teacher的员工姓名、年龄
mysql> select name,age from homework where job = 'teacher';
+------+-----+
| name | age |
+------+-----+
| nick |  28 |
| egon |  35 |
| echo |  12 |
| tank |  25 |
| jinx |  17 |
| crud |  55 |
+------+-----+
6 rows in set (0.00 sec)
------------------------------------------------------------
# 2.查看岗位是teacher且年龄大于30岁的员工姓名、年龄
mysql> select name,age from homework where job = 'teacher' and age > 30;
+------+-----+
| name | age |
+------+-----+
| egon |  35 |
| crud |  55 |
+------+-----+
2 rows in set (0.00 sec)
------------------------------------------------------------
# 3.查看岗位是teacher且薪资在9000-10000范围内的员工姓名、年龄、薪资
mysql> select name,age,salary from homework where job = 'teacher' and salary>9000 and salary<10000;
+------+-----+--------+
| name | age | salary |
+------+-----+--------+
| tank |  25 |   9500 |
+------+-----+--------+
1 row in set (0.00 sec)
------------------------------------------------------------
# 4.查看岗位描述不为NULL的员工信息
mysql> select * from homework where job != 'NULL';
+----+------+-----+--------+---------+
| id | name | age | salary | job     |
+----+------+-----+--------+---------+
|  1 | tbw  |  22 |   5000 | winder  |
|  2 | nick |  28 |  10000 | teacher |
|  3 | egon |  35 |  80000 | teacher |
|  4 | echo |  12 | 150000 | teacher |
|  5 | tank |  25 |   9500 | teacher |
|  6 | jinx |  17 |  66666 | teacher |
|  7 | crud |  55 |   9000 | teacher |
+----+------+-----+--------+---------+
7 rows in set (0.00 sec)
------------------------------------------------------------
# 5.查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name,age,salary from homework where job = 'teacher' and salary in (10000,9000,30000);
+------+-----+--------+
| name | age | salary |
+------+-----+--------+
| nick |  28 |  10000 |
| crud |  55 |   9000 |
+------+-----+--------+
2 rows in set (0.00 sec)
------------------------------------------------------------
# 6.查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name,age,salary from homework where job = 'teacher' and salary not in (10000,9000,30000);
+------+-----+--------+
| name | age | salary |
+------+-----+--------+
| egon |  35 |  80000 |
| echo |  12 | 150000 |
| tank |  25 |   9500 |
| jinx |  17 |  66666 |
+------+-----+--------+
4 rows in set (0.00 sec)
------------------------------------------------------------
# 7.查看岗位是teacher且名字是jin开头的员工姓名、年薪
mysql> select name,salary*12 from homework where job = 'teacher' and name like 'jin%';
+------+-----------+
| name | salary*12 |
+------+-----------+
| jinx |    799992 |
+------+-----------+
1 row in set (0.00 sec)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!