zoukankan      html  css  js  c++  java
  • day34作业

    作业:
    	1. 查看岗位是teacher的员工姓名、年龄
    	2. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
    	3. 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
    	4. 查看岗位描述不为NULL的员工信息
    	5. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
    	6. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
    	7. 查看岗位是teacher且名字是jin开头的员工姓名、年薪
    
    --创建表
    create table info(
    	id int unsigned primary key auto_increment,
    	name char(25) not null,
    	age int,
    	station char(25),
    	salary decimal(7,2)
    )charset=utf8;
    
    
    --插入数据
    insert into info (name,age,station,salary) values ('engon',25,'teacher',51234.45),
    ('tank',35,'teacher',10000.23),('jinse',40,'teacher',23111.55),('老张',32,'清洁工',9000.00),
    ('neo',24,null,12000.29),('法老',23,'赛车手',40000.23),('jingou',18,'学生',1200.00);
    
    --1. 查看岗位是teacher的员工姓名、年龄
    select name,age from info where station='teacher';
    +-------+------+
    | name  | age  |
    +-------+------+
    | engon |   25 |
    | tank  |   35 |
    | jinse |   40 |
    +-------+------+
    
    --2. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
    mysql> select name,age from info where station='teacher' and age>30;
    +-------+------+
    | name  | age  |
    +-------+------+
    | tank  |   35 |
    | jinse |   40 |
    +-------+------+
    
    --3. 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
    select name,age,salary from info where station='teacher' and (salary between 9000 and 10000);
    
    --4. 查看岗位描述不为NULL的员工信息
    mysql> select * from info where station is not null;
    +----+--------+------+---------+----------+
    | id | name   | age  | station | salary   |
    +----+--------+------+---------+----------+
    |  1 | engon  |   25 | teacher | 51234.45 |
    |  2 | tank   |   35 | teacher | 10000.23 |
    |  3 | jinse  |   40 | teacher | 23111.55 |
    |  4 | 老张   |   32 | 清洁工  |  9000.00 |
    |  6 | 法老   |   23 | 赛车手  | 40000.23 |
    |  7 | jingou |   18 | 学生    |  1200.00 |
    +----+--------+------+---------+----------+
    
    --5. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
    select name,age,salary from info where station='teacher' and salary in (10000,9000,30000);
    
    --查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
    select name,age,salary from info where station='teacher' and salary not in (10000,9000,30000);
    
    --7. 查看岗位是teacher且名字是jin开头的员工姓名、年薪
    mysql> select name,salary*12 as '年薪' from info where station='teacher' and name like 'jin%';
    +-------+-----------+
    | name  | 年薪      |
    +-------+-----------+
    | jinse | 277338.60 |
    
  • 相关阅读:
    grep命令、sed 命令 、awk命令、uniq命令
    正则表达式学习(python之re模块)
    linux目录结构
    shell之find命令详解
    shell之 ps、kill、killall命令详解
    linux用户及权限
    C#中数据类型char*,const char*和string的三者转换
    C#中通过SendARP读取MAC地址
    C#对字典Dictionary 的添加,遍历,移除系列操作
    CMD命令行实现复制一张图片1000份:
  • 原文地址:https://www.cnblogs.com/setcreed/p/11760730.html
Copyright © 2011-2022 走看看