I need to run a query in phpmyadmin that joins wp_users with wp_usermeta on the user_id to ID. I have the below so far.
SELECT
wp_users.ID AS 'User ID',
wp_users.display_name AS 'Name',
meta_value AS 'Representative'
FROM wp_usermeta JOIN wp_users ON wp_usermeta.user_id=wp_users.ID
WHERE `meta_key` = 'representative' AND `meta_value` LIKE '%%'
ORDER BY wp_users.ID
This works (or worked) but I am not sure it is the correct to accomplish this. I need 8 different meta_key/meta_value pairs I just don’t know how to add them….
If you need more information I am happy to supply it…
2
Answers
WordPress is built on mySQL and php, so I see no reason not to. Will often be faster when have lots of absraction.
It should be possible to use this too I would think:
https://developer.wordpress.org/reference/functions/get_user_meta/
View:
If you just looking to get value based on different keys, you can do like this:
If this is working, you can add aliases after making sure you code works.