This works if I remove the final JOIN line, but I'm not sure why it won't work with it. The last two JOIN statements are attempting to grab data ('meta_value') from different rows in the same table, the names of which can only be found by reading another corresponding column ('meta_key') in the same table. All this while joining everything on the user_id common in all 3 tables.
SELECT mod_membership.uid,
mod_membership.wp_user_id,
mod_membership.status,
mod_membership.last_login,
mod_membership.membership_type,
mod_membership.membership_expiration,
wp_users.user_login,
wpm_a.meta_value AS first_name
FROM mod_membership
JOIN wp_users ON wp_users.ID = mod_membership.wp_user_id
JOIN wp_usermeta AS wpm_a ON wpm_a.user_id = mod_membership.wp_user_id WHERE wpm_a.meta_key = 'first_name'
JOIN wp_usermeta AS wpm_b ON wpm_b.user_id = mod_membership.wp_user_id WHERE wpm_b.meta_key = 'last_name'
How can I get this third JOIN to work, or use another method to get these results in a single result set, grouped on user_id?