Re: Query Problem - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Query Problem
Date
Msg-id 4254F351.2020707@archonet.com
Whole thread Raw
In response to Query Problem  (Abdul Wahab Dahalan <wahab@mimos.my>)
List 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


pgsql-sql by date:

Previous
From: Abdul Wahab Dahalan
Date:
Subject: Query Problem
Next
From: bandeng
Date:
Subject: Re: [despammed] Crosstab function