Re: Need help building SQL query - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: Need help building SQL query
Date
Msg-id 20051205164611.GB12513@wolff.to
Whole thread Raw
In response to Need help building SQL query  ("Robert Blixt" <robert.blixt@transpa.se>)
Responses Re: Need help building SQL query  ("Robert Blixt" <robert.blixt@transpa.se>)
List pgsql-novice
On Mon, Dec 05, 2005 at 10:28:04 +0100,
  Robert Blixt <robert.blixt@transpa.se> wrote:
>
> Timereportbreak consists of four breaks for
> each timereport. They are ordered by the
> indexnumber (0-3). They are connected to the
> timereport table using the column timereportid.
>
> What I would like to retrieve is all columns from timereport
> and the four timereportbreaks connected to the timereport table.
> However, since each break is not a separate column I am not
> sure how to solve this. And since this database already has data
> in it. I can't remodel the table. This is the output I want:

Normally you want to do this by joining to Timereportbreak once for each
break (i.e. 4 times) using a different table alias for each join. Then
you can use the a different condition on indexnumber for each alias to
get the appropiate break.

pgsql-novice by date:

Previous
From: "Luis Silva"
Date:
Subject: fk problems with 0..n relations
Next
From: Ângelo Marcos Rigo
Date:
Subject: Date Format Question