Skip site navigation (1) Skip section navigation (2)

Two joins on same foreign key

From: Anony Mous <a(dot)mous(at)shaw(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Two joins on same foreign key
Date: 2004-01-30 22:03:35
Message-ID: 00bb01c3e77c$e8bfa2e0$7402a8c0@PETER (view raw or flat)
Thread:
Lists: pgsql-general
Hi,

 

I'm fairly new to this database, and have read much discussion on
sub-queries.  I've seen that they can be great for some queries, and
downright slow for others.  I have a table with two foreign keys referencing
another table, like:

 

Table #1

employee_id (pk)

employee_name

 

Table #2

teamleader_employee_id

backup_employee_id

 

both fields in table 2 need to do a lookup in table 1 to get the name of the
actual employee.  Do I need to use nested queries to accomplish this?  Any
help is greatly appreciated!

 

-AM

Responses

pgsql-general by date

Next:From: Ed L.Date: 2004-01-30 22:19:56
Subject: Re: DB cache size strategies
Previous:From: Gregory S. WilliamsonDate: 2004-01-30 21:46:33
Subject: Re: IDENT and pg_hda.conf

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group