title: Get data from WHERE Postgresql
body: <p>I have this tables: <code>users</code> <code>contacts</code> and <code>user_providers</code>, this is the structure of each one: </p>
  
  <p><a href="https://i.stack.imgur.com/VKeYc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VKeYc.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/ujhsw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ujhsw.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/07eez.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/07eez.png" alt="enter image description here"></a></p>
  
  <p>I want to get all the contacts from a specific user id in contacts table and user_provider provider_name in user_providers , i have this query </p>
  
  <pre><code>SELECT c.id, c.contact_name,c.description,c.discharge,c.latitude,c.longitude,c.town,c.country,c.province,
    (SELECT array_agg(DISTINCT cn.number) FROM contact_numbers cn WHERE cn.contact_id = c.id) AS numbers,
    (SELECT array_agg(DISTINCT ce.email)  FROM contact_emails  ce WHERE ce.contact_id = c.id) AS emails
    FROM
     contacts c,
     user_providers po
    WHERE
     c.user_id = 1 and po.provider_name = 'google'
    ORDER BY
     c.id;
  </code></pre>
  
  <p>But when im trying to get the data it comes like this:
  <a href="https://i.stack.imgur.com/tmJP6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tmJP6.png" alt="enter image description here"></a></p>
  
  <p>The query doesnt respect the provider_name, it returns all contacts related only with a specific user id.</p>
  
  <p>Image from stored data:
  <strong>contactsTable</strong>
  <a href="https://i.stack.imgur.com/fU8dL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fU8dL.png" alt="enter image description here"></a>
  <strong>user_provider Table</strong>
  <a href="https://i.stack.imgur.com/Soe9I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Soe9I.png" alt="enter image description here"></a></p>
  
  <p>I appreciate any help! </p>