Alphabetic Pager Class

From: Dani Castaños <dcastanos(at)androme(dot)es>
To: pgsql-php(at)postgresql(dot)org
Subject: Alphabetic Pager Class
Date: 2007-06-21 08:41:12
Message-ID: 467A39A8.6060008@androme.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hello!

I'm trying to build an alphabetic pager class. For instance, an address
book ordered by the Last Name where only results begining with A are
shown, and A - B - C - D - ... links below to change the letter which
i'm filtering for.
The point is I don't want to have enabled those links wich have no
occurrences in them. So, I'm wondering which is the best way to do the
query.

My first thought to know how many results are there for each, is to do
something like:
SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'A%' );
SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'B%' );
SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'C%' );
...
and so on. But obviously, it is not an effcient way to do this.
Is it possible to reduce this to only one query??

Thank you in advance.

Dani

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Rafael Mora 2007-06-21 10:48:00 Alphabetic Pager Class
Previous Message Mihail Mihailov 2007-06-13 21:47:48 Re: php, postgresql and graphical images