zoukankan      html  css  js  c++  java
  • MySQL 表记录查询小练习

    表记录查询小练习

    1. 查看岗位是teacher的员工姓名、年龄
    2. 查看岗位是teacher且年龄大于26岁的员工姓名、年龄
    3. 查看岗位是teacher且薪资在12000-16000范围内的员工姓名、年龄、薪资
    4. 查看岗位描述不为NULL的人员信息
    5. 查看岗位是teacher且薪资是10000或14000员工姓名、年龄、薪资
    6. 查看岗位是teacher且薪资不是10000或14000的员工姓名、年龄、薪资
    7. 查看岗位是teacher且名字是b开头的员工姓名、薪资
    mysql> select * from t1;
    +----+---------+-----+---------+--------+----------+
    | id | name    | age | job     | salary | job_desc |
    +----+---------+-----+---------+--------+----------+
    |  1 | alpha   |  18 | student |      0 | NULL     |
    |  2 | bravo   |  25 | teacher |  10000 | python   |
    |  3 | charlie |  26 | teacher |  12000 | NULL     |
    |  4 | delta   |  27 | teacher |  14000 | golang   |
    |  5 | echo    |  28 | teacher |  16000 | NULL     |
    +----+---------+-----+---------+--------+----------+
    
    
    
    
    mysql> select name,age from t1 where job='teacher';
    +---------+-----+
    | name    | age |
    +---------+-----+
    | bravo   |  25 |
    | charlie |  26 |
    | delta   |  27 |
    | echo    |  28 |
    +---------+-----+
    4 rows in set (0.00 sec)
    
    mysql> select name,age from t1 where job='teacher'and age>26;
    +-------+-----+
    | name  | age |
    +-------+-----+
    | delta |  27 |
    | echo  |  28 |
    +-------+-----+
    2 rows in set (0.00 sec)
    
    mysql> select name, age, salary from t1 where job='teacher'and salary between 12
    000 and 16000;
    +---------+-----+--------+
    | name    | age | salary |
    +---------+-----+--------+
    | charlie |  26 |  12000 |
    | delta   |  27 |  14000 |
    | echo    |  28 |  16000 |
    +---------+-----+--------+
    3 rows in set (0.00 sec)
    
    mysql> select * from t1 where job_desc is not NULL;
    +----+-------+-----+---------+--------+----------+
    | id | name  | age | job     | salary | job_desc |
    +----+-------+-----+---------+--------+----------+
    |  2 | bravo |  25 | teacher |  10000 | python   |
    |  4 | delta |  27 | teacher |  14000 | golang   |
    +----+-------+-----+---------+--------+----------+
    2 rows in set (0.00 sec)
    
    mysql> select name, age, salary from t1 where job='teacher'and salary in (10000,
     14000);
    +-------+-----+--------+
    | name  | age | salary |
    +-------+-----+--------+
    | bravo |  25 |  10000 |
    | delta |  27 |  14000 |
    +-------+-----+--------+
    2 rows in set (0.00 sec)
    
    mysql> select name, age, salary from t1 where job='teacher'and salary not in (10
    000, 14000);
    +---------+-----+--------+
    | name    | age | salary |
    +---------+-----+--------+
    | charlie |  26 |  12000 |
    | echo    |  28 |  16000 |
    +---------+-----+--------+
    2 rows in set (0.00 sec)
    
    mysql> select name, salary from t1 where name like 'b%';
    +-------+--------+
    | name  | salary |
    +-------+--------+
    | bravo |  10000 |
    +-------+--------+
    1 row in set (0.00 sec)
    
  • 相关阅读:
    thinkphp5 tp5 命名空间 报错 Namespace declaration statement has to be the very first statement in the script
    开启 php 错误 提示 php-fpm 重启 nginx 500错误 解决办法 wdlinux lnmp 一键包 php脚本无法解析执行
    js 设置 cookie 定时 弹出层 提示层 下次访问 不再显示 弹窗 getCookie setCookie setTimeout
    php 二维数组 转字符串 implode 方便 mysql in 查询
    nginx 重启 ps -ef|grep nginx kill -HUP 主进程号
    jquery bootstrap help-block input 表单 提示 帮助 信息
    jquery 倒计时 60秒 短信 验证码 js ajax 获取
    jQuery如何获取同一个类标签的所有的值 遍历
    linux下C语言文件操作相关函数
    gcc,gdb用法
  • 原文地址:https://www.cnblogs.com/bigb/p/11761576.html
Copyright © 2011-2022 走看看