day 34 作业

柔情痞子 提交于 2019-12-02 20:04:26

增 create table teacher_list(id int,name char(11),age int,gangwei char(11),money int,sex enum('male','female') not null) charset=utf8;

insert into teacher_lis(id,name,age,gangwei,money,sex) values(1,'nick',32,'teacher',10000,'male');

insert into teacher_list(id,name,age,gangwei,money,sex) values(1,'nick',32,'teacher',10000,'male');

改属性 alter table teacher_list change id id int auto_increment primary key;

insert into teacher_list(name,age,gangwei,money,sex) values('tank',22,'teacher',11000,'female');

insert into teacher_list(name,age,gangwei,money,sex) values('json',30,'teacher',30000,'male');

insert into teacher_list(name,age,gangwei,money,sex) values('liuweicheng',23,'teahcer',9000,'female');

 insert into teacher_list(name,age,gangwei,money,sex) values('kaola',23,'teahcer',20000,'female');

结果:
select *from teacher_list;
+----+-------------+------+-------------+-------+--------+
| id | name | age | gangwei | money | sex |
+----+-------------+------+-------------+-------+--------+
| 1 | nick | 32 | teacher | 10000 | male |
| 2 | tank | 22 | teacher | 11000 | female |
| 3 | json | 30 | teacher | 30000 | male |
| 4 | sean | 50 | chengxuyuan | 20000 | female |
| 5 | liuweicheng | 23 | teahcer | 9000 | female |
| 6 | kaola | 23 | teahcer | 20000 | female |
+----+-------------+------+-------------+-------+--------+

1. 查看岗位是teacher的员工姓名、年龄
select name,age from teacher_list where gangwei='teacher';

2. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
select name,age from teacher_list where gangwei='teacher' and age>30;

3. 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
select name,age,money from teacher_list where gangwei='teacher' and money between 9000 and 10000;

4. 查看岗位描述不为NULL的员工信息
 select * from teacher_list where gangwei is null;
    
5. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
select name,age,money from teacher_list where money=10000 or money=9000 or money=30000;

6. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
select name,age,money from teacher_list where money in (10000,30000,9000);

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