Re: Problems with select statement

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Lynna Landstreet <lynna(at)spidersilk(dot)net>
Cc: PgSQL-Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Problems with select statement
Date: 2006-01-19 20:47:45
Message-ID: 20060119123234.M31364@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Thu, 19 Jan 2006, Lynna Landstreet wrote:

> On 1/19/06 9:55 AM, Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> wrote:
>
> > What does something like:
> > select * from
> > users_to_plans p inner join
> > users u using (user_id) left join
> > relation_types r using (relation_type_id) left join
> > languages l using (language_id)
> > where p.plan_id = [some plan number here]
> > order by u.relation_type_id
> >
> > give you?
>
> Yay! That worked perfectly! Thank you!

Okay, if that works, that probably implies that some of the users aren't
matching up with relation_types or languages. Are you getting NULL outputs
for the r and/or l columns for the people that were missing before?

> I really need to read up on the different kinds of joins. I'm still not
> clear on how all that works. I've done queries across multiple tables, but
> only in the fairly simple form that was in my previous e-mail, which
> obviously is not suitable for all situations.

There's a little information in the documentation for SELECT about the
different types.

> The one PostgreSQL book I have ("Beginning Databases with PostgreSQL" by
> Richard Stones and Neil Matthew) doesn't go into a lot of detail on them -
> would you happen to know of any online tutorials about that sort of thing?

I don't know how good they are, but...
http://www.devx.com/dbzone/Article/17403/0/page/1
http://www.w3schools.com/sql/sql_join.asp

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Frank Bax 2006-01-19 20:54:50 Re: Problems with select statement
Previous Message Lynna Landstreet 2006-01-19 19:47:53 Re: Problems with select statement