Re: Query Problem

From: Richard Huxton <dev(at)archonet(dot)com>
To: Abdul Wahab Dahalan <wahab(at)mimos(dot)my>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query Problem
Date: 2005-04-07 08:46:09
Message-ID: 4254F351.2020707@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message bandeng 2005-04-07 09:46:06 Re: [despammed] Crosstab function
Previous Message Abdul Wahab Dahalan 2005-04-07 07:16:26 Query Problem