SELECT DISTINCT u.first, u.last FROM users u, user_friends f
WHERE f.userId = 1 AND u.id = f.friendId
ORDER BY u.first ASC, u.last ASC
Essentially what I’m trying to do is get a list of all the users who are friends of the current user (whose id is 1 in this case), in the ascending order of both the first and last names.
So Alice Anna would be displayed above Alice Zanna.
However right now only the first name is being ordered, i.e Alice Anna and Alice Zanna are both displayed above Bob Anna, but Alice Zanna is being displayed above Alice Anna if it was added to the db before her.
Any ideas on how to make it correctly order both the first and last names?
How about sorting the concatonated first and last name: