数据库
首页 > 数据库> > MySQL 学习笔记(4):实例查询

MySQL 学习笔记(4):实例查询

作者:互联网

select count(*) from employees group by sex;

seelct count(*) from employees where politicalstatus<>'党员';

select empid,empname,deptname from employees e
inner join departments d on e.deptid=d.deptid;

select e.empid,empname,salary from employees e
inner join salary s on e.empid=s.empid;

select empname,deptname from employees e
inner join departments d on e.depid=d.detpid
where leader is null;

select depitd,count(*) from employees group by deptid having count(*)>4;

select e.deptid,deptname from employees e
inner join departments d on e.deptid=d.deptid
group by e.deptid having count(*)>4;

select empid,empname from employees e
inner join departments d on e.deptid=d.deptid
where deptname in('开发部','测试部');

select empname,politicalstatus from employees e
inner join departments d on e.deptid=d.deptid
where deptname='市场部' and sex='女';

select empname,salary from employees e
left join salary s on e.empid=s.empid;

select sum(salary) from employees e
inner join salary s on e.empid=s.empid
where not empname like'孙%';

标签:deptid,empid,join,--,employees,笔记,实例,MySQL,select
来源: https://blog.csdn.net/hao2ik/article/details/118657624