Data explorer doesn't show email address with a where clause

I’m trying to run a data explorer query to allow me to collect email addresses of the users signing up for our community. The primary goal here is to try to find out if they are a customer or partner of our company, assuming that they didn’t use a personal email address, then I can add them to the appropriate group.

The problem I’m having is that with a where clause in my query I get NULL returned on the email address in most cases. Here is the query I’m running:

SELECT u.username AS "username", u.email
FROM users u
WHERE u.created_at > '2017-09-11'

If I run this I get the NULL for email but otherwise it works. I read through the original data explorer thread and saw an example using user ID, which works if I set it to 0 in my where clause like this:

SELECT u.username AS "username", u.email
FROM users u
WHERE  u.id > 0

This works as expected. But if I change it to be above a certain value, in my case the last user to sign up before we opened the community up was 384, I get the same NULL values for email:

SELECT u.username AS "username", u.email
FROM users u
WHERE  u.id > 384

It feels like this is a bug as I wouldn’t expect the where clause to cause email addresses not to be shown, but it also seems to work inconsistently. I’m on a Discourse hosted account if that helps troubleshoot things.

Emails have been split out to their own table. Use the schema lookup on the right to find user_emails.

4 Likes

I did look through that, but why does it work sometimes and not others? Maybe it was changed after I started using it and those are legacy entries?

That’s exactly right. New users aren’t getting the column filled out, but it’s not deleted because not all the code has been updated yet.

3 Likes

OK thanks, that makes sense. I’ll work out the new table, thanks for the quick response.

2 Likes