dadamssg87 Posted November 26, 2011 Share Posted November 26, 2011 Is there a way in sql to order rows by a last name and then within the blocks of the same last name, by first name? For example, Abe Adams Corey Adams Terry Alberts Christi Baron John Bellamie Zachary Bellamie Travis Mathews Jon Morgan You'll notice Adams and Bellamie both have two people and they then ordered by their first name. Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/ Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2011 Share Posted November 26, 2011 You can ORDER BY any number of parameters. Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/#findComment-1291337 Share on other sites More sharing options...
dadamssg87 Posted November 26, 2011 Author Share Posted November 26, 2011 i realize that but if i only order by last name, the first name doesn't get taken into account if there are several names with the same last name Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/#findComment-1291403 Share on other sites More sharing options...
PFMaBiSmAd Posted November 27, 2011 Share Posted November 27, 2011 ORDER BY last_name_column, first_name_column Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/#findComment-1291447 Share on other sites More sharing options...
fenway Posted November 27, 2011 Share Posted November 27, 2011 Assuming you've stored them separately, of course. Also, alphabetical sorting isn't technically correct when it comes to last names. Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/#findComment-1291474 Share on other sites More sharing options...
dadamssg87 Posted November 27, 2011 Author Share Posted November 27, 2011 what do you mean by that, fenway? Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/#findComment-1291501 Share on other sites More sharing options...
fenway Posted November 27, 2011 Share Posted November 27, 2011 what do you mean by that, fenway? I mean that "McMahon" is supposed to be sorted before "Mackenzie". Link to comment https://forums.phpfreaks.com/topic/251839-order-by-last-name-and-first-name/#findComment-1291569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.