zoukankan      html  css  js  c++  java
  • 数据表操作练习

    通过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)
    
  • 相关阅读:
    Android tcpdump 抓包
    Android CursorAdapter 查询联系人过滤
    Android 项目打包成apk文件
    解决Centos 6.3 中 gedit中文乱码问题
    在Linux(centos)系统上用手机调试android程序(eclipse)
    系统定时关机命令–shutdown
    使用gdb Server调试嵌入式程序
    Vim 错误排查方法
    通过netstat命令查看进程与端口的对应关系
    dexpler的使用方法
  • 原文地址:https://www.cnblogs.com/jinhongquan/p/11761537.html
Copyright © 2011-2022 走看看