thomjjames Posted November 30, 2005 Share Posted November 30, 2005 Hi everyone, i was wondering if anyone out there knows how to list mySQL results in alphabetical order with each letter having its own group [probably doesn't make much sense, so...]. So for example it would look like this: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] A All the people whos name begins with A. B All the people whos name begins with B. C All the people whos name begins with C and so on and so on. The only way i know how to do this would be to make separate recordsets for each letter of the alphabet [abit long winded] and i was hoping someone might know how to do this with a for loop or something similar. any suggestions would be brilliant Thanks TOM Quote Link to comment https://forums.phpfreaks.com/topic/2957-alphabetic-list-of-sql-results-with-each-letter-in-a-group/ Share on other sites More sharing options...
zq29 Posted December 14, 2005 Share Posted December 14, 2005 This has absolutly nothing to do with core PHP hacking. Moved to our MySQL forum. Quote Link to comment https://forums.phpfreaks.com/topic/2957-alphabetic-list-of-sql-results-with-each-letter-in-a-group/#findComment-10201 Share on other sites More sharing options...
ryanlwh Posted December 14, 2005 Share Posted December 14, 2005 [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] name, LEFT(name,1) AS initial FROM people ORDER BY initial ASC, name ASC [!--sql2--][/div][!--sql3--] Quote Link to comment https://forums.phpfreaks.com/topic/2957-alphabetic-list-of-sql-results-with-each-letter-in-a-group/#findComment-10211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.