# Export all contacts with more than one company

**URL:** https://forum.mautic.org/t/export-all-contacts-with-more-than-one-company/10542
**Category:** General Discussion
**Created:** [May 29, 2018, 4:57am UTC](https://forum.mautic.org/t/export-all-contacts-with-more-than-one-company/10542 "2018-05-29T04:57:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ivan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ivan/32/756_2.png) [@ivan](https://forum.mautic.org/u/ivan)
#### Post date: [May 29, 2018, 4:57am UTC](https://forum.mautic.org/t/export-all-contacts-with-more-than-one-company/10542/1 "2018-05-29T04:57:56Z")

</div>

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

Thanks in advance for your help.  
Regards,  
Ivan

---

<div class="post-metadata">

### Author: ![ivan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ivan/32/756_2.png) [@ivan](https://forum.mautic.org/u/ivan)
#### Post date: [June 7, 2018, 6:39am UTC](https://forum.mautic.org/t/export-all-contacts-with-more-than-one-company/10542/2 "2018-06-07T06:39:18Z")

</div>

Hi,  
someone can help me pls?

Thanks in advance for your help.  
Regards,  
Ivan

---

<div class="post-metadata">

### Author: ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)
#### Post date: [June 8, 2018, 1:19am UTC](https://forum.mautic.org/t/export-all-contacts-with-more-than-one-company/10542/3 "2018-06-08T01:19:17Z")

</div>

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:

```auto
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
;

```

---

<div class="post-metadata">

### Author: ![ivan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ivan/32/756_2.png) [@ivan](https://forum.mautic.org/u/ivan)
#### Post date: [June 12, 2018, 6:04am UTC](https://forum.mautic.org/t/export-all-contacts-with-more-than-one-company/10542/4 "2018-06-12T06:04:42Z")

</div>

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.
