Let's see if I can describe this succinctly:
I have several tables that I want to join. Primarily, I'm looking for invoice records (invoices) which don't have any line item entries (in transactions). Here's a query which works:
select
invoices.ID,
invoices.ClientName,
invoices.OrderTotal,
transactions.Quantity,
transactions.UnitPrice,
transactions.ItemID,
transactions.Extension
FROM
invoices LEFT JOIN transactions
ON invoices.ID = transactions.InvoiceID
Really a simple query, you can see this will produce a rough invoice format, and the "childless" invoice records will show NULL for the transaction records.
HERE IS THE PROBLEM:
The field transactions.ItemID is a foreign key to another table, so how do I left join THAT table (items) to the transactions table? If I just add the items table on later and say "WHERE items.ID = transactions.ItemsID" , I'll lose my NULL records which is what I wanted to see in the first place.
Basically logically it'd be expressed as:
table1 LEFT JOIN (table2 LEFT JOIN table3)
but i'm not quite sure of the syntax.
Many thanks,
Sam Fullman