join table with empty fields and default - Mailing list pgsql-general

From quickcur@yahoo.com
Subject join table with empty fields and default
Date
Msg-id 1153597662.359117.314080@i3g2000cwc.googlegroups.com
Whole thread Raw
Responses Re: join table with empty fields and default
List pgsql-general
Hi, suppose I have two tables

table User
{
    id integer,
    name text,
    address text
}

Table UserWork
{
    userid integer references User(id),
    work text
}

Suppose I have three users

id    name    address
1     Tony      main street
2     Peter     Big ave
3     Richard  Loop Blvd

And two of them work

UserWork
userid        work
1               programming
3               studying

I would like to join table user and userwork, where if a user has a
work, I list it. If he does not, I give it some default value "no work"

Join User and UserWork
id    name    address              work
1     Tony      main street        programming
2     Peter     Big ave              no work
3     Richard  Loop Blvd          studying

How can I write the sql?

Thanks,

qq


pgsql-general by date:

Previous
From: "Jasbinder Bali"
Date:
Subject: ECPG. Badly stuck
Next
From: Michael Fuhr
Date:
Subject: Re: join table with empty fields and default