From: Paul Lambert <paul.lambert@autoledgers.com.au>
To: pgsql-sql@postgresql.org
Subject: Join question
Date: Fri, 27 Jul 2007 09:33:20 +0800
Message-ID: <46A94B60.4030901@autoledgers.com.au> (raw)
I have a database in a parts sales environment that I am having a little
difficulty with a join query - trying to figure out which way to join
things.
I have a parts_invoice_header table, containing the header record for
each invoice.
I have a parts_invoice_lines table, containing the parts details for
each invoice.
I have a parts_invoice_sundries table, containing additional sundry
charges (freight, delivery etc) on each invoice.
For each record in the invoice_header table, there can be 0 or more
records in either of the two other tables.
I want to search for an invoice in the header file and get the details
of all matching records from the lines and sundries. Assuming the lines
and sundries tables both have the same column names, I should be able to
end up with something like:
table | header header line/sundries
|
column| Invoice number customer item amount
line | 1111 abc 457ABC 10.00
sundry| 1111 abc FREIGHT 5.00
line | 1111 abc FGOIL 15.00
What would be the best method of joining to create a result-set such as
this?
TIA for any assistance,
P.
--
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: <46A94B60.4030901@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