X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 094DA9FA5CD for ; Sat, 1 Jul 2006 18:21:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 74344-01 for ; Sat, 1 Jul 2006 18:21:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from burta.hst.terra.com.br (burta.hst.terra.com.br [200.176.10.199]) by postgresql.org (Postfix) with ESMTP id 608E89FA5C3 for ; Sat, 1 Jul 2006 18:21:26 -0300 (ADT) Received: from tacamaca.hst.terra.com.br (tacamaca.hst.terra.com.br [200.176.10.13]) by burta.hst.terra.com.br (Postfix) with ESMTP id E26164B78054 for ; Sat, 1 Jul 2006 18:21:21 -0300 (BRT) X-Terra-Karma: -2% X-Terra-Hash: 5ba5d0ba91e29a79c160a2000c05ecfd Received-SPF: pass (tacamaca.hst.terra.com.br: domain of terra.com.br designates 200.176.10.13 as permitted sender) client-ip=200.176.10.13; envelope-from=carlosreimer@terra.com.br; helo=reimer; Received: from reimer (201-24-120-14.bnut3702.dsl.brasiltelecom.net.br [201.24.120.14]) (authenticated user carlosreimer@terra.com.br) by tacamaca.hst.terra.com.br (Postfix) with ESMTP id 9FE314344065 for ; Sat, 1 Jul 2006 18:21:21 -0300 (BRT) Reply-To: From: "Carlos H. Reimer" To: Subject: Left join? Date: Sat, 1 Jul 2006 18:21:34 -0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.866 tagged_above=0 required=5 tests=BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, RCVD_IN_BL_SPAMCOP_NET, SPF_PASS X-Spam-Level: X-Archive-Number: 200607/10 X-Sequence-Number: 25584 Hi, In the following table, codsol, codate and codfec are foreign keys referencing table func and I need some help to codify a SELECT command that produces the following result set but instead of codsol, codate and codfec I need the respectives names (column nome from table func). postgres=# select * from reqtran; codreq | codsol | codate | codfec --------+--------+--------+-------- 1 | | | 2 | 1 | | 3 | 1 | 1 | 4 | 1 | 1 | 1 (4 rows) Thanks in advance, Carlos __________________________________________________ Table definitions: postgres=# \d func Table "public.func" Column | Type | Modifiers --------+---------+----------- codfun | integer | not null nome | text | Indexes: "func_pkey" PRIMARY KEY, btree (codfun) postgres=# \d reqtran Table "public.reqtran" Column | Type | Modifiers --------+---------+----------- codreq | integer | not null codsol | integer | codate | integer | codfec | integer | Indexes: "reqtran_pkey" PRIMARY KEY, btree (codreq) Foreign-key constraints: "reqtran_codate_fkey" FOREIGN KEY (codate) REFERENCES func(codfun) "reqtran_codfec_fkey" FOREIGN KEY (codfec) REFERENCES func(codfun) "reqtran_codsol_fkey" FOREIGN KEY (codsol) REFERENCES func(codfun) __________________________________________________ Table contents: postgres=# select * from func; codfun | nome --------+------- 1 | nome1 2 | nome2 3 | nome3 (3 rows) postgres=# select * from reqtran; codreq | codsol | codate | codfec --------+--------+--------+-------- 1 | | | 2 | 1 | | 3 | 1 | 1 | 4 | 1 | 1 | 1 (4 rows)