Have your tried ORDER BY last_name?
Yes I tried, the problem is that there is no column named “last_name”.
There is meta_key clolum that the value his’last_name’ and his ‘meta_value” is tha last name.
for example:
umeta_id.user_id…meta_key..meta_value
5……………5……..last_name..Jacson
21………….1……..last_name..Weston
27………….3……..first_name.Bill
30………….3……..last_name..Gates
You’re totally right. Completely forgot how the tables where constructed! Sorry about that. How about something like this?
SELECT * FROM wp_users INNER JOIN wp_usermeta ON (wp_users.id = wp_usermeta.user_id) WHERE meta_key ="last_name" ORDER BY meta_value
I don’t know exactly what you need, but that’ll give you the user fields ordered by the user last name.
Thanks for your comment, INNER JOIN isn’t needed beacuse I’m currectly using the user meta table.
This is my query right now:
$author_subscriper = $wpdb->get_results(“SELECT * from $wpdb->usermeta WHERE meta_key = ‘wp_capabilities’ AND meta_value = ‘a:1:{s:10:\”subscriber\”;b:1;}’ AND WHERE meta_key =’last_name’ ORDER BY ‘meta_value'”);
Isn’t working for me… (It doesn’t show result at all)
Looking forward for your replay, thanks 🙂
Get it work! thank you very much!
this is my query now:
$author_subscriper = $wpdb->get_results(“SELECT * from $wpdb->usermeta WHERE meta_key = ‘last_name’ ORDER BY BINARY meta_value”);