From: Paul Lambert <paul.lambert@autoledgers.com.au>
To: pgsql-sql@postgresql.org
Subject: Re: Join question
Date: Fri, 27 Jul 2007 10:18:36 +0800
Message-ID: <46A955FC.8000105@autoledgers.com.au> (raw)
In-Reply-To: <00a001c7cff0$300ff000$9b0014ac@wbaus090>
References: <00a001c7cff0$300ff000$9b0014ac@wbaus090>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: paul.lambert@autoledgers.com.au
Subject: Re: Join question
In-Reply-To: <46A955FC.8000105@autoledgers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox