Hi,
I have a table of names in the format: firstname lastname. Is it possible to somehow ORDER BY the lastname? I guess it would be done by splitting the field into two and ordering it by the second piece?
Thanks for any assitance, ~Oni.
Are talking about a database table? If so, you can just use ORDER BY surely? Would you be able to give a little more detail please?
yes I'm talking about a table :]
I can't use ORDER BY because I want it to be ordered by their last name. The name field contains both their first name and lastname in that order.
Why dont you just Make two columns in your DB and have your form or whatever your doing submit the values into the respective columns
then your result query woud be something like
SELECT * FROM tableName ORDER BY lastname
Sorry about the delayed reply. Can I assume you're using MySQL?
SELECT name, SUBSTRING_INDEX( name, ' ', -1 ) as lastname FROM table ORDER BY lastname;