I have to join my current query that joins two tables to a third table.
This third table contains two columns I am interested in retrieving: comments and a last contact date
Some records in the third table may not have any comments or last contact date values for some customers
The joining fields of table 3 are: customer_id, entity_id, invoice_id
I am attaching my current query (the one with two tables)
b.name AS 'CUSTOMER NAME',
a.journal_customer_id AS 'CUSTOMER ID',
a.entity_id AS 'ENTITY ID',
a.recv_invoice_id AS 'INVOICE ID',
a.invoice_date AS 'INVOICE DATE'
a.amount_15 AS 'AMOUNT',
FROM RG_AR_COLLECTION a
JOIN RECEIVABLES_CUSTOMER b
ON b.id = a.journal_customer_id
WHERE a.entity_id IN ('10') < this will be a dynamic value - eventually.
AND a.related_currency_id = 'USD'
and the new one (the one that gets just the two new columns from the third table)
COMMENTS AS 'REMARKS',
LAST_CONTACT_DATE AS 'LAST CONTACT DATE'
If I could get help joining to this table without getting duplicates.
my record should be something like:
customer name, customer id, entity id, invoice id, invoice date, amount, remarks (it is ok if no value), last contact date (it is ok if no value)
I added alias to the columns on the first query so it is easy to identify the columns to join to.
Thank you very much for your help.