Flutter开发App的未来及其在各行业的应用潜力分析
827
2022-08-30
mysql select查询基本运算符练习题
# 1.选择工资不在5000到12000的员工的姓名和工资
SELECT last_name ,salary
FROM employees
WHERE salary BETWEEN 5000 AND 12000;
#第二种写法
SELECT last_name ,salary
FROM employees
WHERE salary >=5000 AND salary <=12000;
# 2.选择在20或50号部门工作的员工姓名和部门号
SELECT last_name ,department_id
FROM employees
WHERE department_id IN (20,50);
SELECT last_name,department_id
FROM employees
WHERE department_id=20 OR department_id=50;
# 3.选择公司中没有管理者的员工姓名及job_id
DESC employees;
SELECT last_name ,job_id ,manager_id
FROM employees
WHERE manager_id IS NULL
SELECT last_name ,job_id,manager_id
FROM employees
WHERE manager_id <=> NULL
SELECT last_name ,job_id ,manager_id
FROM employees
WHERE ISNULL(manager_id)
# 4.选择公司中有奖金的员工姓名,工资和奖金级别
SELECT last_name ,salary ,commission_pct
FROM employees
WHERE commission_pct IS NOT NULL
# 5.选择员工姓名的第三个字母是a的员工姓名
SELECT last_name
FROM employees
WHERE last_name LIKE '__a%';
# 6.选择姓名中有字母a和k的员工姓名
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%' AND last_name LIKE '%k%'
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%' && last_name LIKE '%k%'
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%k%' OR last_name LIKE '%k%a%';
#7.显示出表 employees 表中 first_name 以 'e'结尾的员工信息
SELECT first_name
FROM employees
WHERE first_name RLIKE 'e$'
SELECT first_name
FROM employees
WHERE first_name REGEXP 'e$'
# 8.显示出表 employees 部门编号在 80-100 之间的姓名、工种
SELECT last_name,job_id,department_id
FROM employees
WHERE department_id BETWEEN 80 AND 100;
# 9.显示出表 employees 的 manager_id 是 100,101,110 的员工姓名、工资、管理者id
SELECT last_name ,salary,manager_id
FROM employees
WHERE manager_id IN (100,101,110);
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~