Unix Technical Forum

Employees without managers

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:24 AM
Max
 
Posts: n/a
Default Employees without managers

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:24 AM
Max
 
Posts: n/a
Default Re: Employees without managers

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 11:24 AM
Arakrys
 
Posts: n/a
Default Re: Employees without managers

D*rn, you're not watching for 9 minutes and people are bl***y helping
themselves ! Outrage!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 11:24 AM
strawberry
 
Posts: n/a
Default Re: Employees without managers

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:26 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com