Is there a way I can order a group of users by first name and if a user didn't enter a first name order that user by last name or if they didn't enter a last name order the开发者_StackOverflow中文版m by middle name?
You could do something like this:
SELECT fields
FROM table
WHERE condition
ORDER BY first_name, last_name, middle_name ASC
I'm assuming 'didn't enter' equates to a null field.
SELECT fields
FROM table
WHERE condition
ORDER BY COALESCE(first_name, last_name, middle_name)
精彩评论