Search code examples
databasearrayssortingcategoriesalphabetical

Categorize a list of names from database


I have a database that contains names. I'm needing to take those names and sort them alphabetically into 4 ARRAY's -> (A-F) (G-L) (M-R) (S-Z). Any strategies out there that i could use?


Solution

  • Query the database 4 times, once for each range. A query looks like this:

    select * from T where Name >= 'G' and name < 'M' order by name