From: | "David M(dot) Kaplan" <dkaplan(at)bio(dot)puc(dot)cl> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | join queries |
Date: | 2001-04-13 15:28:19 |
Message-ID: | 3AD71B12.677FB100@genes.bio.puc.cl |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I have a query which seems like it should easy, but isnt. I have two
tables, a and b that look like this:
a)
id | c1
--+--
1 | a
2 | b
3 | c
b)
id | c2
--+--
2 | b
and I would like to do a query which returns
id | c1 | c2
--+--+--
1 | a |
2 | b | b
3 | c |
The simplest thing I could find was
SELECT a.*, (SELECT b.c2 WHERE a.id=b.id) AS c2;
This works, but is extremely slow for more complex examples. Is there a
better way to do this in postgresql?? I think MS Access has inner and
outer joins to solve this problem. Is there a postgresql equivalent?
Thanks for the help.
David Kaplan
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-04-13 16:17:54 | Re: Repairing bad table? |
Previous Message | J.H.M. Dassen Ray | 2001-04-13 15:07:53 | Re: Debian stable install problems |