Reputation: 35341
I want to be able to create an alphabet pagination of some sort, where you have A-Z and each have a link to filter by letter, however, I want to be able to label the letters with a background indicating that there are records that starts with the letter.
It looks like this so far, showing labelled letters:
On another thing, I'm using pagination for the results which is obviously using LIMIT
on the query, so I cannot use SUBSTRING
on the column then lay them out with the letters, I was wondering if it's possible to do it in one query while the search picks out the records with the records that starts with the letter.
I need to be able to show the letters that has the filled background, indicating that there is at least one record per letter, if there isn't any records to a letter, it shouldn't show the filled background.
Is it possible to do this; within one query?
Upvotes: 0
Views: 801
Reputation: 255005
I was wondering if it's possible to do it in one query
The wish of having everything in just one query makes no sense. Each query should do one and just one particular piece of work.
So your script obviously consists of 2 parts for now:
LIMIT
So perform 2 different queries.
Upvotes: 3