X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7441E53823 for ; Thu, 7 Apr 2005 09:46:18 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88315-07 for ; Thu, 7 Apr 2005 08:46:11 +0000 (GMT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 0C756537E1 for ; Thu, 7 Apr 2005 09:46:09 +0100 (BST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) id 1DJSeQ-000Pr2-Eu; Thu, 07 Apr 2005 08:46:10 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E670E179C1; Thu, 7 Apr 2005 09:46:08 +0100 (BST) Message-ID: <4254F351.2020707@archonet.com> Date: Thu, 07 Apr 2005 09:46:09 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Abdul Wahab Dahalan Cc: pgsql-sql@postgresql.org Subject: Re: Query Problem References: <5039595.1112858186520.SLOX.WebMail.wwwrun@openx.mimos.my> In-Reply-To: <5039595.1112858186520.SLOX.WebMail.wwwrun@openx.mimos.my> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.059 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/68 X-Sequence-Number: 20961 Abdul Wahab Dahalan wrote: > If I've 2 tables like this: > > Country table : with 2 fields (country and id) > > Country id > England E > France F > Japan J > > FlightTo table : with 2 fields(Flight ID and Destination) > > FlightID Destination > B1 E,J > B2 E,F > B3 J,F Simplest solution is to correct this table - "Destination" should be two fields (e.g. dest_from,dest_to). Then you could do something like: SELECT flight_id, c1.country as from_country, c2.country as to_country FROM flight_to, country c1, country c2 WHERE dest_from = c1.id AND dest_to = c2.id ; -- Richard Huxton Archonet Ltd