# Query on the database to find email

**URL:** https://meta.discourse.org/t/query-on-the-database-to-find-email/107420
**Category:** Development
**Created:** [January 24, 2019, 2:33pm UTC](https://meta.discourse.org/t/query-on-the-database-to-find-email/107420 "2019-01-24T14:33:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gael\_Koch](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@Gael\_Koch](https://meta.discourse.org/u/Gael_Koch)
#### Post date: [January 24, 2019, 2:33pm UTC](https://meta.discourse.org/t/query-on-the-database-to-find-email/107420/1 "2019-01-24T14:33:52Z")

</div>

Hi,

I want to create a query with the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin to find all the email addresses of the users. I tried to create a query on the “users” table but it’s not stored there.  
I tried to find it on internet but couldn’t find a solution. I don’t even know if it’s possible.

Any idea ? Thanks

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [January 24, 2019, 2:49pm UTC](https://meta.discourse.org/t/query-on-the-database-to-find-email/107420/2 "2019-01-24T14:49:59Z")

</div>

Emails are stored in a separate database table. You can look them up in [data explorer](https://meta.discourse.org/t/32566?silent=true) using something like:

```SQL
SELECT users.id as user_id, user_emails.email 
FROM users 
LEFT JOIN user_emails 
ON users.id = user_emails.user_id 
AND user_emails.primary

```

---

<div class="post-metadata">

### Author: ![Gael\_Koch](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@Gael\_Koch](https://meta.discourse.org/u/Gael_Koch)
#### Post date: [January 24, 2019, 3:07pm UTC](https://meta.discourse.org/t/query-on-the-database-to-find-email/107420/3 "2019-01-24T15:07:24Z")

</div>

Nice. That sorted it ! Many thanks
