Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    Cebu City
    Posts
    9

    Arrow Unanswered: problem with looping in mysql query

    There are 3 tables :
    PERSONS (personID PRIMARY KEY, firstName, lastName)
    EMPLOYEES (employeeID PRIMARY KEY, personID FOREIGN KEY)
    OVERTIME (overtimeID PRIMARY KEY, employeeID FOREIGN KEY
    supervisorID)

    In 1 query, I wish to retrieve the names of all employee's
    who filed for overtime as well as the names of their supervisors.
    Ideally, you can get the names of supervisors from PERSONS table.
    The problem is that you can also get the names of the employees
    from the PERSONS table. How do i go about this problem?

  2. #2
    Join Date
    May 2002
    Location
    Vancouver Canada
    Posts
    26
    You can join the same table twice using this syntax

    INNER JOIN Table AS Table_1 ON Table_1.id = OtherTable.id
    INNER JOIN Table AS Table_2 ON Table_2.id = AnotherTable.id

Posting Permissions

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