[thelist] Q on SQL 'ORDER BY' - part 2

jsWalter jsWalter at torres.ws
Sun Apr 11 04:06:21 CDT 2004

OK, now I have another issue, similar, but not quite.

I am looking at 2 different tables, pulling data from both...

SELECT contacts.con_id, contacts.con_name,
       contacts.con_title, contacts.st_id,
 FROM contacts, stations
 WHERE contacts.st_id = stations.st_id
 ORDER BY contacts.con_title, contacts.con_name;

Sometimes contacts.con_name has data, sometime not.

Sometimes contacts.con_title has data, sometime not.

Sometimes both have data.

But at least one of these is filled.

What I'm wanting to do is sort by NAME, and if NAME is empty, then by TITLE.

Below is my real screwy results.

Is what I'm looking to possible in mySQL?

Thanks again.


» E Collman
» Janet Heatherman
» K Olmstead
» M Carbaugh
» M Zukerman
» P Mutino
» Patrick Ryan
» Scott Shannon
» Lisa Jackson, Creative Services Manager
» Director of Marketing and Promotions
» Director of Sales
» Chris Ingram, Director, News and Programming
» Linda Wnek, Diversity Recruitment Coordinator
» Dawn Levine, GSM
» Human Resources
» Human Resources
» Cecilia Quintero, Human Resources
» Human Resources / Receptionist Position
» Thomas Holmes, Marketing Director
» Greg O'Catlin, News Director
» Cathy Younkin, News Director
» Personnel
» Production Manager
» Frank Abbadessa, Sales Manager
» Matt Ross, VP Sales & Marketing

More information about the thelist mailing list