The WordPress database schema for Users is as follows:
TABLE wp_users
ID
user_login
user_pass
user_nicename
user_email
...
TABLE wp_usermeta
umeta_id
user_id
meta_key
meta_value
Now, it’s the wp_usermeta table that I want to be able to write a SQL statement for.
In one row, meta_key is “first_name” … how do I write a SQL query that will pull out the meta_value where meta_key is equal to “first_name”? This does not work:
SELECT meta_value FROM wp_usermeta WHERE meta_value = "first_name";
It should be
Notice you had
WHERE meta_valueinstead ofWHERE meta_key