Thread: Fill multiple fields through one INNER JOIN
guys, 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. thanks.
On 1/29/07, Peter Dawn <petedawn@gmail.com> wrote: > guys, > > 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. Personally I always find example data helpful to try and understand what people want to achieve .... Cheers, Andrej
I'll second that. I can't see what Peter's trying to do. -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Andrej Ricnik-Bay Sent: 06 February 2007 17:47 To: Peter Dawn Cc: pgsql-novice@postgresql.org Subject: Re: [NOVICE] Fill multiple fields through one INNER JOIN On 1/29/07, Peter Dawn <petedawn@gmail.com> wrote: > guys, > > 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. Personally I always find example data helpful to try and understand what people want to achieve .... Cheers, Andrej ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings
> 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);