left outer join on multi tables

From: quickcur(at)yahoo(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: left outer join on multi tables
Date: 2006-10-11 04:51:16
Message-ID: 1160542276.013714.300220@e3g2000cwe.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi, here are my tables

table name
{
id integer primary key
first_name text,
middle_name text,
last_name text
}

table address
{
id integer primary key
number int,
street text,
city text,
state text
}

table work
{
id integer primary key
hours text,
shift
}

table person
{
id integer primary key
namid integer references name(id),
addressid integer referenes address(id),
workid integer references work(id)
}
nameid, addressid or workid in person table may be empty.

I would like to make a view which shows all information about a person
in one row

first_name, last_name, street, city, workhours, ...

In the peron table, if the workid, addressid, or nameid is empty, just
do not display the correspodent information.

I think I need left outer join, but I do not know how to use it. Could
anyone help?

Thanks,

qq

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma Jr 2006-10-11 05:19:45 Re: restoring a file system backed-up data dir
Previous Message David Fetter 2006-10-11 04:16:42 Re: more anti-postgresql FUD

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Broersma Jr 2006-10-11 05:31:47 Re: left outer join on multi tables
Previous Message David Fetter 2006-10-11 04:16:42 Re: more anti-postgresql FUD