Skip to content

Instantly share code, notes, and snippets.

@macmladen
Last active June 22, 2021 13:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save macmladen/04d8c6cb26a4d2d4008f3b3963c65d06 to your computer and use it in GitHub Desktop.
WordPress select users and extended profile data which is stored in same column. Lookup hint https://dba.stackexchange.com/questions/9011/proper-use-of-lookup-tables
SELECT ID, user_email email, user_registered registered, user_status status,
(SELECT meta_value FROM `pltfrm_usermeta` WHERE meta_key='last_activity' AND user_id=u.ID ) as active,
(SELECT meta_value FROM `pltfrm_usermeta` WHERE meta_key='first_name' AND user_id=u.ID ) as Name,
(SELECT meta_value FROM `pltfrm_usermeta` WHERE meta_key='last_name' AND user_id=u.ID ) as Surname
FROM `pltfrm_users` u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment