数据表操作练习

Posted jinhongquan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据表操作练习相关的知识,希望对你有一定的参考价值。

通过mysql新建teacher表如下:

mysql> create table teacher(name char(10)not null default 'xxx',age int not null
 default 0,salary decimal(6,1))charset=utf8;
mysql> insert into teacher(name,age,salary)values('tank',18,32001.5);
mysql> insert into teacher(name,age,salary)values('json',18,32001.5);
mysql> insert into teacher(name,age,salary)values('nick',25,35000.7);
mysql> insert into teacher(name,age,salary)values('echo',26,38000.7);
mysql> select*from teacher;
+------+-----+---------+
| name | age | salary  |
+------+-----+---------+
| tank |  18 | 32001.5 |
| json |  18 | 32001.5 |
| nick |  25 | 35000.7 |
| echo |  26 | 38000.7 |
+------+-----+---------+
4 rows in set (0.00 sec)
1. 查看岗位是teacher的员工姓名、年龄
2. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
3. 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
4. 查看岗位描述不为NULL的员工信息
5. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
6. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
7. 查看岗位是teacher且名字是jin开头的员工姓名、年薪

?

  1. 查看岗位是teacher的员工姓名、年龄
mysql> select name,age from teacher;
+------+-----+
| name | age |
+------+-----+
| tank |  18 |
| json |  18 |
| nick |  25 |
| echo |  26 |
+------+-----+
4 rows in set (0.00 sec)
  1. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
mysql> select name,age from teacher where age>30;
Empty set (0.00 sec)
  1. 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
mysql> select*from teacher where salary>1000 and salary<9000;
Empty set (0.00 sec)
  1. 查看岗位描述不为NULL的员工信息
mysql> select*from teacher where name!=null;
Empty set (0.00 sec)
  1. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name ,age,salary from teacher where salary in(10000,9000,30000);
Empty set (0.00 sec)
  1. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name,age,salary from teacher where salary not in(10000,9000,30000);
+------+-----+---------+
| name | age | salary  |
+------+-----+---------+
| tank |  18 | 32001.5 |
| json |  18 | 32001.5 |
| nick |  25 | 35000.7 |
| echo |  26 | 38000.7 |
+------+-----+---------+
4 rows in set (0.00 sec)
  1. 查看岗位是teacher且名字是jin开头的员工姓名、年薪
mysql> select name,salary from teacher where name like 'jin%';
Empty set (0.00 sec)

以上是关于数据表操作练习的主要内容,如果未能解决你的问题,请参考以下文章

Python练习册 第 0013 题: 用 Python 写一个爬图片的程序,爬 这个链接里的日本妹子图片 :-),(http://tieba.baidu.com/p/2166231880)(代码片段

片段着色器中未使用纹理数据 - OpenGL

csharp Epicor标准练习片段

golang 去练习片段

VSCode自定义代码片段——git命令操作一个完整流程

VSCode自定义代码片段15——git命令操作一个完整流程