Mautic Community Forums

Export all contacts with more than one company

Hello,
is there a way to export all contacts that belong to more than one company?

Thanks in advance for your help.
Regards,
Ivan

Hi,
someone can help me pls?

Thanks in advance for your help.
Regards,
Ivan

Do you have SQL access to the Mautic database? Otherwise, I think you cannot accomplish this from Mautic GUI directly.

SQL - untested! - please insert contact fields to be exported:

SELECT [contact fields to be exported],
       COUNT(c.id)
  FROM leads l
 INNER
  JOIN companies_leads cl
    ON l.id = cl.lead_id
 INNER
  JOIN companies c
    ON cl.company_id = c.id
 GROUP
    BY [contact fields to be exported]
HAVING COUNT(c.id) > 1
;

Thank you so much for your help. I really appreciate it, PeterTL.
Unfortunatly I don’t have SQL access to the Mautic database, so I can not do it.