Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 7C8529FB391 for ; Thu, 21 Jun 2007 07:48:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 76283-03 for ; Thu, 21 Jun 2007 07:48:01 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.232]) by postgresql.org (Postfix) with ESMTP id 26EC79FB3A3 for ; Thu, 21 Jun 2007 07:48:01 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id s16so428892wxc for ; Thu, 21 Jun 2007 03:48:00 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=rRwYSxG7t5/K9zCYM9yEZ5vBSYxtdbn8U6xqx9mEbXkROXOUWeUa3wHui/Y5FbI4ePW/TBMgdh6J/lHFQbWbQALb5wqiVpGbA4wrc6MJXbOH5Bw+CrVj/kSYv3/WLtiAPf+abHTU7oMXzYKLIYaO+pt/QBXsprD80MS9TdLws4U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=m2h0p5Zftz+7tJvD3dE2ZPpAIdJs7GFMa4ulIl+w1OF1zNmldVZevro3gp7Z8LUwh3yUs6WIK4ZyUTvAXZJBbBEo2oixM02zcMJsAe4rsEzVFcvNi0WtC3mWYcYYXNk+z+ynVPGot8uHSMbo9JbPVWCtk+47CvyXH1hiyglJT+0= Received: by 10.90.49.1 with SMTP id w1mr1369489agw.1182422880090; Thu, 21 Jun 2007 03:48:00 -0700 (PDT) Received: by 10.90.115.16 with HTTP; Thu, 21 Jun 2007 03:48:00 -0700 (PDT) Message-ID: <21509df10706210348t55fe6199n8ba21cb9b32780a3@mail.gmail.com> Date: Thu, 21 Jun 2007 06:48:00 -0400 From: "Rafael Mora" To: pgsql-php@postgresql.org Subject: Alphabetic Pager Class In-Reply-To: <21509df10706210345o2a8c8abei75951c0eb8fbe48d@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2881_14495121.1182422880068" References: <467A39A8.6060008@androme.es> <21509df10706210345o2a8c8abei75951c0eb8fbe48d@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.498 tagged_above=0 required=5 tests=BAYES_50=0.001, HTML_40_50=0.496, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200706/11 X-Sequence-Number: 3813 ------=_Part_2881_14495121.1182422880068 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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=F1os 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 > ------=_Part_2881_14495121.1182422880068 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

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=F1os <dcastanos@a= ndrome.es > wrote:=20
Hello!

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

My first thought to know how many results are there for e= ach, is to do
something like:
SELECT COUNT(field) FROM table WHERE UP= PER( field )  LIKE UPPER( 'A%' );
SELECT COUNT(field) = FROM table WHERE UPPER( field )  LIKE UPPER( 'B%' );=20
SELECT COUNT(field) FROM table WHERE UPPER( field )  LIKE UPP= ER( 'C%' );
...
and so on. But obviously, it is not an effcie= nt way to do this.
Is it possible to reduce this to only one query??
=
Thank you in advance.=20

Dani


---------------------------(end of broadcast)------= ---------------------
TIP 7: You can help support the PostgreSQL project= by donating at

        &nbs= p;      http://www.postgresql.org/about/donate

------=_Part_2881_14495121.1182422880068--