From: | "chris smith" <dmagick(at)gmail(dot)com> |
---|---|
To: | Dani Castaños <dcastanos(at)androme(dot)es> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Alphabetic Pager Class |
Date: | 2007-06-21 11:01:06 |
Message-ID: | 3c1395330706210401l14c4656fv2af5787a34d5c80f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
On 6/21/07, Dani Castaños <dcastanos(at)androme(dot)es> wrote:
> 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%' );
select count(*), upper(substr(field, 1, 1)) from table group by
upper(substr(field, 1, 1));
--
Postgresql & php tutorials
http://www.designmagick.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Dani Castaños | 2007-06-21 13:07:46 | Re: Alphabetic Pager Class |
Previous Message | Rafael Mora | 2007-06-21 10:48:00 | Alphabetic Pager Class |