From: | Richard Broersma Jr <rabroersma(at)yahoo(dot)com> |
---|---|
To: | Peter Dawn <petedawn(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Fill multiple fields through one INNER JOIN |
Date: | 2007-02-06 18:50:02 |
Message-ID: | 678206.18948.qm@web31814.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
> i have a table which contains 5 fields, of these 2 fields need to be
> filled in through an inner join from one same table.
>
> now i have managed to fill in one field using the inner join method.
> but the second field also is exactly the same and needs to be filled
> in from the same table, the only difference is the field name is
> different and obviously the content of these two fields is also
> different (but its still coming from the same other table).
>
> so i guess my question is how do i populate two fields using an inner
> join (both these fields contain different data but from the same
> table). i hope i have been able to explain myself.
I think I understand what you are trying to do. However, every foreign key requires it's own
join.
Select
A.field1,
A.field2,
A.field3,
B1.description,
B2.description
from
MainTable A
inner join -- or maybe left outer join
LookupTable B1 on (A.field4FK = B1.PK)
inner join -- or maybe left outer join
LookupTable B2 on (A.field5FK = B2.PK);
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Danielsson | 2007-02-07 15:31:15 | Select maximum amoung grouped sums |
Previous Message | Duncan Garland | 2007-02-06 18:31:54 | Re: Fill multiple fields through one INNER JOIN |