Multiple Foreign Keys to a Single Table (2 replies)

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
Submitted by programmer on Thu, 08/14/2008 - 16:10.

I searched for this topic but the closest thing I found was a listing for Multiple Foreign Keys to Multiple Tables.

I could also have not been searching for the right thing.

I have a table that contains a list of people. And I have another table that has two foreign key columns, each setup as a foreign key to the people table.

I am trying to do a join on the tables so that I can retrieve the names of both people from the people table in one record.

Is this something I can do with a single join or will I need to use nested queries?

Will I need to make a temp table or a view?

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.