Alphabetic Pager Class

From: "Rafael Mora" <moraloco(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Alphabetic Pager Class
Date: 2007-06-21 10:48:00
Message-ID: 21509df10706210348t55fe6199n8ba21cb9b32780a3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi Dani!!

like

SELECT a.COUNT(field), b.COUNT(field),.... FROM table a, table b, table c,
.....
WHERE UPPER( a.field ) LIKE UPPER( 'A%' ) AND
UPPER( b.field ) LIKE UPPER( 'B%' ) AND
.
.
.
.

I think you should change the AND for OR, 'cuz there you can get something
anyways even if you dont have a letter on the table!!

What do u think?
(Q t parece?)

Regards (Saludos)
Rafa
La Victoria, Venezuela

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%' );
> ...
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
>

In response to

Browse pgsql-php by date

  From Date Subject
Next Message chris smith 2007-06-21 11:01:06 Re: Alphabetic Pager Class
Previous Message Dani Castaños 2007-06-21 08:41:12 Alphabetic Pager Class