Created
November 21, 2018 15:47
-
-
Save nicomollet/c3e830ee7c85dfc527089bd9acd9cfe5 to your computer and use it in GitHub Desktop.
Export WordPress users with meta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| t1.ID, t1.user_email, | |
| MAX(CASE WHEN t2.meta_key = 'first_name' THEN meta_value END) AS first_name, | |
| MAX(CASE WHEN t2.meta_key = 'last_name' THEN meta_value END) AS last_name, | |
| MAX(CASE WHEN t2.meta_key = 'paying_customer' THEN meta_value END) AS paying_customer, | |
| MAX(CASE WHEN t2.meta_key = 'billing_title' THEN meta_value END) AS billing_title | |
| FROM th_users AS t1 | |
| INNER JOIN th_usermeta AS t2 ON t1.ID = t2.user_id | |
| GROUP BY t1.ID, t1.user_email |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment