So I wrote this query for a high_school alumni site I'm working on:
SELECT
u.ID, u.user_login,
m1.meta_value AS alumni_first_name,
m2.meta_value AS alumni_last_name,
m3.meta_value AS alumni_class,
m4.meta_value AS wp_capabilities
FROM
wp_users AS u
JOIN
wp_usermeta AS m1 ON (m1.meta_key='first_name' AND m1.user_id=u.ID)
JOIN
wp_usermeta AS m2 ON (m2.meta_key='last_name' AND m2.user_id=u.ID)
JOIN
wp_usermeta AS m3 ON (m3.meta_key='alumni_graduation_year' AND m3.user_id=u.ID)
JOIN
wp_usermeta AS m4 ON (m4.meta_key='wp_capabilities' AND m4.user_id=u.ID)
WHERE
m4.wp_capabilities='a:1:{s:6:"alumni";s:1:"1";}'
With that WHERE on the end, it doesn't work. Just trying to run this through phpMyAdmin at the moment, but eventually I'll need to have it working on the site and I'll need to add some searches and resort columns to what's on the screen. At the moment, I ccan't resort the results I get from the above query in phpMyAdmin either. Can anyone see what I'm missing here?
Thanks,
Shaun