数据表操作练习
通过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开头的员工姓名、年薪
?
- 查看岗位是teacher的员工姓名、年龄
mysql> select name,age from teacher; +------+-----+ | name | age | +------+-----+ | tank | 18 | | json | 18 | | nick | 25 | | echo | 26 | +------+-----+ 4 rows in set (0.00 sec)
- 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
mysql> select name,age from teacher where age>30; Empty set (0.00 sec)
- 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
mysql> select*from teacher where salary>1000 and salary<9000; Empty set (0.00 sec)
- 查看岗位描述不为NULL的员工信息
mysql> select*from teacher where name!=null; Empty set (0.00 sec)
- 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
mysql> select name ,age,salary from teacher where salary in(10000,9000,30000); Empty set (0.00 sec)
- 查看岗位是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)
- 查看岗位是teacher且名字是jin开头的员工姓名、年薪
mysql> select name,salary from teacher where name like 'jin%'; Empty set (0.00 sec)
相关推荐
FellowYourHeart 2020-10-05
bianxq 2020-06-28
景泽元的编程 2020-06-21
韩学敏 2020-06-17
wuhen 2020-06-14
morexyoung 2020-06-13
lanmantech 2020-06-07
敏敏张 2020-06-06
勇往直前 2020-06-01
msmysql 2020-05-29
Noseparte 2020-05-28
zhangxiaojiakele 2020-05-25
CSDN0BLOG 2020-05-16
IBMRational 2020-05-14
Zhangdragonfly 2020-05-14
gamestart0 2020-04-10
仁鱼 2020-05-10
lijiawnen 2020-05-01
dayi 2020-04-29