From: Richard Huxton <dev@archonet.com>
To: Abdul Wahab Dahalan <wahab@mimos.my>
Cc: pgsql-sql@postgresql.org
Subject: Re: Query Problem
Date: Thu, 07 Apr 2005 09:46:09 +0100
Message-ID: <4254F351.2020707@archonet.com> (raw)
In-Reply-To: <5039595.1112858186520.SLOX.WebMail.wwwrun@openx.mimos.my>
References: <5039595.1112858186520.SLOX.WebMail.wwwrun@openx.mimos.my>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, wahab@mimos.my
Subject: Re: Query Problem
In-Reply-To: <4254F351.2020707@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox