MySQL 查询部门人数大于2的员工信息

如下表,查询部门人数大于2的员工信息,并把员工姓名和头衔一起输出出来

1.员工表(employee)

2.部门表(department)

3.Sql语句:

select CONCAT(name,title) ,sex,employee_no,department_id from test.employee where department_id in(select department_id from test.employee group by department_id HAVING(count(department_id)>1));

4.结果

5.主要Concat(string,string,....)和HAVING()的使用

6.太晚了,后续补上。。。哇嘎嘎

如下表,查询部门人数大于2的员工信息,并把员工姓名和头衔一起输出出来 1.员工表(employee) 2.部门表(department) 3.Sql语句: select CONCAT(name,title) ,sex,employee_no,department_id from test.employee where department_id in(select department_id from test.employee group by department_id HAVING(count(department_id)>1)); 4.结果 5.主要Concat(string,string,....)和HAVING()的使用 6.太晚了,后续补上。。。哇嘎嘎
经验分享 程序员 微信小程序 职场和发展