An option is to create a sortfield in your query, something like "SELECT *, CONCAT(nickname, fname) AS sortfield FROM ORDER BY sortfield". I'm assuming MySQL and haven't actually tested this. You may need to check the sql documentation for some of the details.
Tim www.chessish.com <http://www.chessish.com> ---------- From: Dean Householder [SMTP:[EMAIL PROTECTED]] Sent: 15 January 2002 07:35 To: [EMAIL PROTECTED] Subject: PHP array or SQL problem I've got a database with lname (lastname), fname (firstname), and nickname. What I want to do is search by either first name or last name. Either way, I display the nickname instead of the firstname if it exists. I have no problems on the last name, but when I sort by firstname, the people with nicknames that are very different come up at the place where their first name (not the displayed name) is. For example: Adam Smith Joe Schmoe Bill Somebody When Bill Somebody is really William Somebody in the database, his nickname is bill and that's what's displayed but he 'bill' shows up in 'williams' spot. Here is my SQL query: select * from employees order by fname; Should I create an array and sort it there or can I somehow query MySQL to sort by nickname only if it exists and then by fname? Dean -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]