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

query two tables using same lookup table

From: ssylla <stefansylla(at)gmx(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: query two tables using same lookup table
Date: 2012-07-23 03:04:32
Message-ID: 1343012672084-5717583.post@n5.nabble.com (view raw or flat)
Thread:
Lists: pgsql-sql
Dear list, 

assuming I have two tables as follows 

t1: 
id_project|id_auth 
1|1 
2|2 

t2: 
id_project|id_auth 
1|2 
2|1 


and a lookup-table: 

t3 
id_auth|name_auth 
1|name1 
2|name2 

Now I want to query t1 an t2 using the 'name_auth' column of lookup-table
t3, so that I get the following output: 
id_project|name_auth_t1|name_auth_t2 
1|name1|name2 
2|name2|name1 

Any ideas? 

Thanks- 
Stefan



--
View this message in context: http://postgresql.1045698.n5.nabble.com/query-two-tables-using-same-lookup-table-tp5717583.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

Responses

pgsql-sql by date

Next:From: David JohnstonDate: 2012-07-23 04:45:47
Subject: Re: query two tables using same lookup table
Previous:From: Sergey KonoplevDate: 2012-07-20 14:13:31
Subject: Re: DELETE using an outer join

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