习题小结
声明:mysql 总结之路是在b站上观看视频进行总结的,mysql 在我上大学的时候已经学过了,同时也学过sql server了,本次总结看看自己能不能温故知新,让自己更加快速的成长。
本就简单的4到小题,自己也可以试试:
查询员工号为176的员工的姓名和部门编号和年薪
select last_name, department_id,salary *12 *(1+ ifnull(commission_pct,0)) as '年薪' from employees where employee_id = 176;
结果:
查询没有奖金,且工资小于18000的salary, last_name
select salary,last_name from employees where commission_pct is null and salary <18000;
结果:
查询employees 表中 job_id 不为 ‘IT’ 或者 工资为12000的员工信息
select * from employees where job_id <> 'IT' or salary = 12000;
结果:
#查看部门 departments 表的结构。
desc departments;
结果:
查询部门的departments 表中涉及到了那些位置编号
select distinct location_id from departments;
问 select * from employees 和 select * from employees where commission_pct like '%%' and last_name like '%%'; 结果是否一样
答:不一样,当里面有null 时候,就会结果不同,除非数据库中的查找字段没有null 时候。