Display results for each letter
Posted: Thu Sep 23, 2004 1:49 pm
Hi everyone,
I am trying to retrieve data from a MySQL db, and then, for each letter of the alphabet, display the results, in a manner such as:
A: list of articles starting with letter A
B: list of articles starting with letter B
etc...
Right now, I'm doing it with MySQL queries like:
"SELECT col FROM table WHERE col LIKE 'A%'"
"SELECT col FROM table WHERE col LIKE 'B%'"
So I have 26 separate queries, which I don't find very effective. I was wondering if there is a more effective way of doing this, by reusing the same array which would contain all the results (i.e. not just for 1 letter), and looping through it to display results by letter.
Thanks for any input!
I am trying to retrieve data from a MySQL db, and then, for each letter of the alphabet, display the results, in a manner such as:
A: list of articles starting with letter A
B: list of articles starting with letter B
etc...
Right now, I'm doing it with MySQL queries like:
"SELECT col FROM table WHERE col LIKE 'A%'"
"SELECT col FROM table WHERE col LIKE 'B%'"
So I have 26 separate queries, which I don't find very effective. I was wondering if there is a more effective way of doing this, by reusing the same array which would contain all the results (i.e. not just for 1 letter), and looping through it to display results by letter.
Thanks for any input!