Search Postgresql Archives

noobie join question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi List,
I am having trouble trying to figure out
how to get the result listed at the bottom.

I have 3 tables units, types of units which has a description of the units,
and a table that list associations of the units. I can't figure out
how to do the proper joins. Any pointers would be appreciated.

create table types (
       id integer,
       descr varchar(30)
);

COPY types (id, descr) FROM stdin;
1    descr 1
2    descr 2
3    descr 3
4    descr 4
\.

create table units (
       uid integer,
       udevice varchar(30),
       utype integer
);

COPY units (uid, udevice, utype) FROM stdin;
1    aaaaa    1
2    bbbbb    1
3    ccccc    4
4    ddddd    3
\.


create table assoc (
       aid integer,
       src_id integer,
       dest_id integer
);

COPY assoc (aid, src_id, dest_id) FROM stdin;
1    1    2
2    1    3
3    3    4
4    4    2
\.

desired result
aaaaa | descr 1 | bbbbb | descr 1
aaaaa | descr 1 | ccccc | descr 4
ccccc | descr 4 | ddddd | descr 3
ddddd | descr 3 | bbbbb | descr 1


Thanks,
Steve







--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux