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