pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Joining several tables
3+ messages / 3 participants
[nested] [flat]

* Joining several tables
@ 2001-01-22 06:20 Stephan Richter <srichter@cbu.edu>
  2001-01-23 03:35 ` Re: Joining several tables PM <pmeloy@home.negate.spam.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Stephan Richter @ 2001-01-22 06:20 UTC (permalink / raw)
  To: pgsql-sql

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




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

* Re: Joining several tables
  2001-01-22 06:20 Joining several tables Stephan Richter <srichter@cbu.edu>
@ 2001-01-23 03:35 ` PM <pmeloy@home.negate.spam.com>
  0 siblings, 0 replies; 3+ messages in thread

From: PM @ 2001-01-23 03:35 UTC (permalink / raw)
  To: pgsql-sql

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
>





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

* RE: Joining several tables
@ 2001-01-22 18:00 Michael Davis <mdavis@sevainc.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Davis @ 2001-01-22 18:00 UTC (permalink / raw)
  To: 'Stephan Richter' <srichter@cbu.edu>; pgsql-sql

1) Select t1.* from table_1 t1, table2 t2 where t1.column = t2.column;
2) Select t1.* from table_1 t1 join table2 t2 on t1.column = t2.column;


-----Original Message-----
From:	Stephan Richter [SMTP:srichter@cbu.edu]
Sent:	Sunday, January 21, 2001 11:20 PM
To:	pgsql-sql@postgresql.org
Subject:	Joining several tables

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




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


end of thread, other threads:[~2001-01-23 03:35 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-22 06:20 Joining several tables Stephan Richter <srichter@cbu.edu>
2001-01-23 03:35 ` PM <pmeloy@home.negate.spam.com>
2001-01-22 18:00 RE: Joining several tables Michael Davis <mdavis@sevainc.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