Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling the same field twice in one query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Okay, here's the general scenario. I have a list of projects and some info about them in a table called projects_list. I also have a list of people and some info about them in a table called people_list. The projects_list table has a field listing the ID of the person that is the project manager for that project, and it also has a field listing the ID of the person that is the main contact for that project. To write up a generic project info page, I need to know the name of both the project manager and the main contact. Since projects_list merely stores the people's ID numbers, I have to pull that information from people_list, like so:

SELECT projects_list.*, people_list.fullname
FROM projects_list, people_list
WHERE projects_list.manager = people_list.ID
AND projects_list.contact = people_list.ID

You can probably see my problem.. how do I have MySQL pull people_list.fullname once based on projects_list.manager and once based on projects_list.contact? I could do it with sub-selects if they were implemented.. but until then, I'm stuck.

In this instance I could also use two separate queries, but I couldn't if I was trying to get a list of all the projects along with their managers and contacts, so I'd very much like if I could do it in one query.

Anyone have any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top