If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > problem with looping in mysql query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-04, 01:30
shibby1011ph shibby1011ph is offline
Registered User
 
Join Date: Oct 2003
Location: Cebu City
Posts: 9
Arrow 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?
Reply With Quote
  #2 (permalink)  
Old 01-05-04, 14:29
Dylan Leblanc Dylan Leblanc is offline
Registered User
 
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
__________________
http://skyscraperpage.com/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On