I am trying to get a list of all users in WordPress getting the user ID from the user table and some additional meta information from the usermeta table for the corresponding user. I am trying the below code but it's not working. I think I am going wrong in the INNER JOIN part of the statement but I don't know how to correct it.
$sql = "
SELECT {$wpdb->users}.ID,{$wpdb->usermeta}.meta_value
FROM {$wpdb->users},{$wpdb->usermeta}
INNER JOIN {$wpdb->usermeta} ON ({$wpdb->users}.ID = {$wpdb->usermeta}.user_id)
WHERE 1=1 AND {$wpdb->usermeta}.meta_key = 'first_name' OR {$wpdb->usermeta}.meta_key = 'last_name' OR {$wpdb->usermeta}.meta_key = 'dev_capabilities'
";
$users = $wpdb->get_results($sql);
p.s. I realise there's easier ways to get this information in WordPress by using the get_users() function but because this is in a particular action I can't use this method.