This is a discussion on Employees without managers within the MySQL forums, part of the Database Server Software category; --> Hello group, I need to create a query listing employee groups without managers. There are two table: employee and ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello group, I need to create a query listing employee groups without managers. There are two table: employee and manager. All employees are part of a group and each manager manages a group. Therefore, I need to find employee.group without any manager.group. Does anyone know how to do this query? Thank you, Max |
| |||
| On Aug 8, 10:06 am, Max <Maxime.Pla...@gmail.com> wrote: > Hello group, > > I need to create a query listing employee groups without managers. > There are two table: employee and manager. All employees are part of a > group and each manager manages a group. > > Therefore, I need to find employee.group without any manager.group. > > Does anyone know how to do this query? > > Thank you, > Max For the community, here is the solution: SELECT employee.group FROM employee WHERE employee.group NOT IN (SELECT distinct(manager.group) FROM manager) GROUP BY employee.group Cheers, Max |
| ||||
| On 8 Aug, 15:48, Arakrys <Arak...@gmail.com> wrote: > D*rn, you're not watching for 9 minutes and people are bl***y helping > themselves ! Outrage! Well, there is still a better solution... SELECT * FROM table1 t1 LEFT JOIN table2 t1 ON t1.group = t2.group WHERE t2.id IS NULL |