pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to write this query!
2+ messages / 2 participants
[nested] [flat]

* How to write this query!
@ 2003-07-13 16:32 Jo <joacn@yahoo.co.uk>
  2003-07-21 11:46 ` Re: How to write this query! Richard Huxton <richardh@archonet.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Jo @ 2003-07-13 16:32 UTC (permalink / raw)
  To: pgsql-sql

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!! 

Many Thanks!! 

Joe



________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to write this query!
  2003-07-13 16:32 How to write this query! Jo <joacn@yahoo.co.uk>
@ 2003-07-21 11:46 ` Richard Huxton <richardh@archonet.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Huxton @ 2003-07-21 11:46 UTC (permalink / raw)
  To: Jo <joacn@yahoo.co.uk>; 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-07-21 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-13 16:32 How to write this query! Jo <joacn@yahoo.co.uk>
2003-07-21 11:46 ` Richard Huxton <richardh@archonet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox