From: | Frodo Larik <lists(at)e-l33t(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Stuck with references |
Date: | 2005-03-25 15:04:17 |
Message-ID: | 42442871.6000104@e-l33t.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello all,
this is my first post to the list, so please be gentle :-)
I created the following tables (full file can be found here:
http://www.larik.nl/sql/payway.sql ):
CREATE TABLE location (
location_id integer DEFAULT nextval('"location_id_seq"'::text) NOT NULL,
name text NOT NULL,
CONSTRAINT location_pkey PRIMARY KEY (location_id)
) WITH OIDS;
CREATE TABLE payway_profile (
payway_profile_id integer DEFAULT
nextval('"payway_profile_id_seq"'::text) NOT NULL,
location_a integer REFERENCES location (location_id) NOT NULL,
location_b integer REFERENCES location (location_id) NOT NULL,
distance integer NOT NULL,
CONSTRAINT payway_profile_pkey PRIMARY KEY (payway_profile_id)
) WITH OIDS;
Now I wan to do the following:
A select from payway_profile so I also can see the name of location_a
and location_b, instead of the id as defined in the table location.
If there was only reference i could do something like this:
SELECT l.name, pp.distance FROM payway_profile AS pp
INNER JOIN location AS l ON ( pp.location_a = l.location_id );
But now there are two references location_a and location_b, so I don't
know how i can solve this in one query. Is it possible or is it bad design?
Sincerely,
Frodo Larik
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-03-25 15:23:37 | Re: pl/perl problem of memory |
Previous Message | GIROIRE Nicolas (COFRAMI) | 2005-03-25 14:35:20 | pl/perl problem of memory |