I am struggling to get a query to work. The tables involved are acp_tasks
and acp_contacts
the only thing the same in both are the ID acp_contacts.id = acp_tasks.entity_id
.
What I am trying to do is return all the tasks that have been created by different types of Contact. In this example I am trying to recreate the tasks of the Creditor and additional creditor contacts. The different types of contact are in the acp_contact
(creditor_contact, additional_creditor_contact, debtor_contact, additional_debtor_contact)
table
The query below is selecting each task 5 times. Which I am really confused about. could anyone possibly help?
I really appreciate it.
SELECT t.id
, t.document_id
, t.name
, t.customer_notes
, t.expect_response
, t.response_from
, t.task_type
, t.date_entered
, t.date_complete
, t.status
, t.direction
, t.read
, t.debt_id
, t.entity_id
, c.link_type
FROM acp_tasks t
JOIN acp_contacts c
ON c.id = t.entity_id
AND t.status = 'complete'
AND t.public = 'y'
AND t.debt_id = 'qcArxlvANQSEAg4f6c66211cf88'
AND c.link_type IN('creditor_contact','additional_creditor_contact')
ORDER
BY date_complete DESC