I have a query where I want to merge values from the wp_users and wp_meta tables, including the meta values of a given meta key. This key could have multiple entries.
SELECT
u.id,
(select meta_value from wp_usermeta where user_id = u.id and meta_key = 'first_name' limit 1) as first_name,
(select meta_value from wp_usermeta where user_id = u.id and meta_key = 'last_name' limit 1) as last_name,
u.user_email AS email,
u.user_registered AS registered,
(select meta_value from wp_usermeta where user_id = u.id and meta_key = '_example_key') as my_custom_meta_values
FROM wp_users u
This query returns a single column (my_custom_meta_values), containing all the serialised values from wp_usermeta for the given key.
My question is, how do I then loop over these values in PHP? I'm assuming that simply deserialising the row will fail.