Re: Join question - Mailing list pgsql-sql

From Paul Lambert
Subject Re: Join question
Date
Msg-id 46A955FC.8000105@autoledgers.com.au
Whole thread Raw
In response to Re: Join question  ("Phillip Smith" <phillip.smith@weatherbeeta.com.au>)
List pgsql-sql
Phillip Smith wrote:
> Whoops, I forgot the JOIN conditions! Fixed below
> 
> -----Original Message-----
> From: Phillip Smith [mailto:phillip.smith@weatherbeeta.com.au] 
> Sent: Friday, 27 July 2007 11:47
> To: 'pgsql-sql@postgresql.org'
> Subject: RE: [SQL] Join question
> 
> 
> This might give you a starting point if I understand you correctly...
> 
> SELECT h.invoice_number,
>      h.customer,
>      l.item,
>       l.amount
> FROM    lines AS l
> JOIN    headers AS h ON l.invoice_number = h.invoice_number
> UNION
> SELECT h.invoice_number,
>      h.customer,
>      s.item,
>       s.amount
> FROM    sundries AS s
> JOIN    headers AS h ON s.invoice_number = h.invoice_number
> ORDER BY invoice_number, item
> 

Forgot all about union - I had two individual views, one for 
invoice+parts, one for invoice+sundries... didn't think of union to 
combine the two views together.

Perfect solution, you've done it for me again Phillip, thanks.

-- 
Paul Lambert
Database Administrator
AutoLedgers


pgsql-sql by date:

Previous
From: "Phillip Smith"
Date:
Subject: Re: Join question
Next
From: Tom Lane
Date:
Subject: Re: unique index on fields with possible null values