Skip to content

Instantly share code, notes, and snippets.

@atopal
Created August 26, 2016 10:48
Show Gist options
  • Save atopal/af1dbc087b31e5837f38b27fa3a9d76a to your computer and use it in GitHub Desktop.
Save atopal/af1dbc087b31e5837f38b27fa3a9d76a to your computer and use it in GitHub Desktop.
active accounts with Persona but not github credentials
SELECT DISTINCT `auth_user`.`email`, `auth_user`.`first_name`, `auth_user`.`last_name`
FROM
(SELECT *
FROM `socialaccount_socialaccount`
WHERE `socialaccount_socialaccount`.`provider`="persona") A
LEFT JOIN
(SELECT *
FROM `socialaccount_socialaccount`
WHERE `socialaccount_socialaccount`.`provider`="github") B
ON A.`user_id` = B.`user_id`
JOIN `auth_user` ON `auth_user`.`id` = A.`user_id`
WHERE B.`user_id` IS NULL
AND `auth_user`.`is_active` = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment