I'm not quite following what you are asking. If you want to limit the result to only 10 items per page, you're going to need to come up with some paginating code (it actually isn't that hard). You could easily get more than 10 names starting with a single letter.

If you want to create specific links that show only name beginning with a letter or set of letters, then you need to do a search:
SELECT fn, ln FROM directory WHERE ln like "A%" ORDER BY ln,fn LIMIT 10
or for a group of letters
SELECT fn, ln FROM directory WHERE ln between "BAAA" AND "CZZZ" ORDER BY ln,fn LIMIT 10


That's actually kind a fudge on the search for a group of letters. Technically you should search for "between A and D" to get all names beginning with B-C, but I think it reads better this way from a coding readability standpoint.

On Tuesday, September 9, 2003, at 02:55 PM, Dave Dash wrote:

I have a page that is a directory of names ordered by lastname, firstname (e.g. SELECT fn, ln FROM directory ORDER BY ln, fn LIMIT 0,10).

I have it paginated so that there are 10 results per page. What I'd like to do instead of having page numbers (which can be unhelpful when trying to page through people's names) is be more like a phone book and let people click on links that are the first letters of their last names

For example, let's say my result set for

SELECT fn, ln FROM directory ORDER BY ln, fn LIMIT 30, 10

is

Jackson
Johnson
Knutson
Kraig
Liver
Lombard
Marx
Maxx
Milton
Nixon

The page link would be

J-N

I know how to get the letters for one page (well I think I do at least), but I want to get them for all pages

So basically I'd have something like this for my page list:

A B-C D E-G F-H I J-N O-Z

and clicking on each page would result in entries only from that letter. The trick is I don't want more than 10 entries a page. Is there an easy way to do this? Possibly in a single query?

Thanks

-dd


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to