I have a query...
SELECT tblInvoices.invoice_id, tblInvoices.customer_id, tblInvoices.InvoiceDate, tblInvoices.PaidDate, tblInvoices.DueDate, tblInvoices.Notes, SUM tblInvoiceItem.Quantity tblInvoiceItem.Price) (1 + $g_GST) + tblInvoices.Shipping - tblInvoices.Deposit AS Total FROM tblInvoices INNER JOIN tblInvoiceItem ON tblInvoices.invoice_id = tblInvoiceItem.invoice_id GROUP BY tblInvoices.invoice_id, tblInvoices.customer_id, tblInvoices.InvoiceDate, tblInvoices.PaidDate, tblInvoices.DueDate, tblInvoices.Shipping, tblInvoices.Deposit, tblInvoices.Notes HAVING tblInvoices.customer_id = $cid $filter ORDER BY $sortKey";
it gets data from two tables with a 1 to many relationship.
one row in 'tblInvoice' can have many rows in 'tblInvoiceDetails'.
the problem is that there is not always data in the 'tblInvoiceItem'.
when there is no data in the 'tblInvoiceDetails' table, the query doesn't return any rows.
I would like it to return all rows that exist in 'tblInvoice' regardless of what is in 'tblInvoiceDetails'.
thnx