Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006

    Unanswered: Please help! - Need Query Statement


    I am a newbie at mysql and I need help with a query statement.

    I have 2 tables

    1. Table of Managers
    2. Table of Employees

    I need to write a query that will pull all the Managers records and beside each manager display all the employees that they manage. Some manager have manage no employees so they need to display 0.

    Please let me know if anyone can help. Thanks in advance. Any help would be much appreciated.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    sounbds like flaky table design to me
    a manager is also an employee, and may also have a manager, ok there are some odd situatuations where a manager may not be employed by the company (could be a contractor or delegate from another organasiation)

    the managed by should be a column in the employee table (self referncing FK to employee ID). the manager ID whould be nullable as some mangaers don't have managers (eg directors)

    the alternative design is to have a separate table which identifies the entity or role
    eg finance dept, accounts payable, receivable etc.... and store a manager there, and associate an employee with a department. that way round when a new manager is appointed its a single change rather than a bulk update of the employee table
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts