I want to create a view from both the wp_users and wp_usermeta tables so that I can query rows in the view from an external application. Basic auth details are stored in wp_user
$sql= "SELECT
u1.parent_id,
m1.meta_value AS headline,
m2.meta_value AS profilephoto
FROM wp_vandor u1
JOIN wp_usermeta m1 ON (m1.user_id = u1.child_id AND m1.meta_key = 'headline')
JOIN wp_usermeta m2 ON (m2.user_id = u1.child_id AND m2.meta_key = 'profilephoto')
WHERE m1.user_id != $currentuser_id";
$classifieds = $wpdb->get_results($sql);
foreach ($classifieds as $classified) { ?>
profilephoto; ?>
headline; ?>