MySQL 2.条件查询

MySQL 2.条件查询

1. 查询工资大于 12000 的员工姓名和工资

select CONCAT(first_name , last_name),salary
from employees
where salary > 12000;

2. 查询员工号为 176 的员工的姓名和部门号和年薪

select CONCAT(first_name , last_name) , department_id , salary*12 yearSalay -- 重命名为yearSalay 可以不加它
from employees
where employee_id = 176;

3. 选择工资不在 5000 到 12000 的员工的姓名和工资

select CONCAT(first_name , last_name) , salary
from employees
WHERE salary not BETWEEN 5000 and 12000;

4. 选择在 20 或 50 号部门工作的员工姓名和部门号

select CONCAT(first_name , last_name), department_id
from employees
WHERE department_id  BETWEEN 20 and 50;

5. 选择公司中没有管理者的员工姓名及 job_id

select CONCAT(first_name , last_name) , job_id
from employees
where manager_id = null;

6. 选择公司中有奖金的员工姓名,工资和奖金级别

select CONCAT(first_name , last_name),salary , commission_pct
from employees
where commission_pct is not null;

7. 选择员工姓名的第三个字母是 a 的员工姓名

select CONCAT(first_name , last_name) 
from employees
where concat(first_name , last_name) like '__a%';

8. 选择姓名中有字母 a 和 e 的员工姓名

select concat(first_name , last_name)
from employees
where concat(first_name , last_name) like '%a%'and concat(first_name , last_name) like '%e%'

9. 显示出表 employees 表中 first_name 以 'e’结尾的员工信息

select *
from employees
where first_name like '%e' 

10. 显示出表 employees 部门编号在 80-100 之间 的姓名、职位

select concat(first_name , last_name), job_id
from employees 
where department_id between 80 and 100;

11. 显示出表 employees 的 manager_id 是 100,101,110 的员工姓名、职位

select concat(first_name , last_name) , job_id
from employees
where manager_id in (100,101,110);

mysql文件:https://download.csdn.net/download/qq_52102663/85172984

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

温水煮小杜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值