pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PM <pmeloy@home.negate.spam.com>
To: pgsql-sql@postgresql.org
Subject: Re: Joining several tables
Date: Mon, 22 Jan 2001 19:35:50 -0800
Message-ID: <94itt6$1cmu$1@news.tht.net> (raw)
References: <4.3.1.0.20010122001803.00a99dd0@198.78.130.6>

As long as the contactid is not null in any of the tables its easy. You
didn't give any column name information so I'll wing it. Not knowing the
relationships between the tables means this might get you a fair amount of
repeat data. If there is only ONE row in each table for a given contactid
it'll work ok.

SELECT street,phone,contname FROM Address a, PhoneNumber p, Contact c WHERE
a.contactid=p.contactid and a.contactid=c.contactid;

I have no affiliation with cold remedy manufacturers (heh, Contact c...)

"Stephan Richter" <srichter@cbu.edu> wrote in message
news:4.3.1.0.20010122001803.00a99dd0@198.78.130.6...
> Hello, I have the following situation:
>
> I have an Address, PhoneNumber and Contact table all having a contactid in
> common, but sometimes the phone number does not exist.
>
> I want to join these three tables. How do I do that? I could not find the
> syntax for multiple tables...
>
> Regards,
> Stephan
> --
> Stephan Richter
> CBU - Physics and Chemistry Student
> Web2k - Web Design/Development & Technical Project Management
>





view thread (3+ messages)

Message-ID: <94itt6$1cmu$1@news.tht.net>
Permalink:  ../94itt6$1cmu$1@news.tht.net/
Also on:    postgresql.org/message-id/94itt6$1cmu$1@news.tht.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pmeloy@home.negate.spam.com
  Subject: Re: Joining several tables
  In-Reply-To: <94itt6$1cmu$1@news.tht.net>
  References: <4.3.1.0.20010122001803.00a99dd0@198.78.130.6> <94itt6$1cmu$1@news.tht.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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