ORDER BY - mix two fields

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a table with business names and contact lastnames and
firstnames. Some records don't have a business name, and some don't
have contact names. Does anyone know whether it is possible to have
results sorted by business name, unless the field is empty, in which
case, use the surname followed by the first name in place of the
business name. i.e.

table: people
fields: business name, lastname, firstname

"A to Z Spares", "", ""
"", "Naylor", "Bob"
''Zack's Auto" "Zachariah", "Brown"

ordered result:

A to Z Spares
Naylor, Bob
Zack's Auto

Re: ORDER BY - mix two fields

On 22/12/2005, m.k.ball@btinternet.com wrote:

Quoted text here. Click to load it

   IF(business_name = '', NULL, business_name),
   CONCAT(lastname, firstname)


Site Timeline