From: | Richard Huxton <richardh(at)archonet(dot)com> |
---|---|
To: | Jo <joacn(at)yahoo(dot)co(dot)uk>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How to write this query! |
Date: | 2003-07-21 11:46:02 |
Message-ID: | 200307211246.02554.richardh@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Sunday 13 July 2003 17:32, Jo wrote:
> These are my PostgreSQL tables:
>
> pid | name
> 1 | A
> 2 | B
> 3 | C
> 4 | D
> 5 | E
>
> tid | pid 1 | pid 2 | pid 3
> 1 | 1 | 2 | 3
>
> Bascially, I would like to write a query to list only
> the names which their "pid" match those pids in the
> other table. If anyone knows, pls help!!
Jo - not sure how your message took this long to reach the list, but it
doesn't look like someone has answered, so...
SELECT DISTINCT a.name FROM table_a AS a, table_b as b WHERE a.pid=b.pid1 OR
a.pid=b.pid2 OR a.pid=b.pid3;
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | jwsacksteder | 2003-07-21 12:10:43 | query or function |
Previous Message | Richard Huxton | 2003-07-21 11:42:49 | Re: Why their is a limit in Postgresql (psql) Parameters..? |