• 数据表操作练习


    通过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)
    
  • 相关阅读:
    [poj 1741]Tree 点分治
    [bzoj 3251]树上三角形
    [bzoj 3687]简单题 bitset的运用
    HDU [P5015] 233 Matrix
    POJ 3233
    洛谷 [P3629] 巡逻
    POJ 2728 Desert King
    洛谷 [P2886] 牛继电器Cow Relays
    POJ 1734 Sightseeing trip
    洛谷 [P3008] 道路与航线
  • 原文地址:https://www.cnblogs.com/jinhongquan/p/11761537.html
Copyright © 2020-2023  润新知