增 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%';