X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2200A475F5F for ; Tue, 25 Mar 2003 11:48:01 -0500 (EST) Received: from t-9.net (unknown [64.246.36.43]) by postgresql.org (Postfix) with SMTP id 68E54475E4D for ; Tue, 25 Mar 2003 11:48:00 -0500 (EST) Received: (qmail 32326 invoked by uid 0); 25 Mar 2003 14:50:28 -0000 Received: from localhost (HELO seahat.com) (127.0.0.1) by localhost with SMTP; 25 Mar 2003 14:50:28 -0000 Received: from 65.102.128.233 (SquirrelMail authenticated user snubber@seahat.com) by fordparts.com with HTTP; Tue, 25 Mar 2003 08:50:28 -0600 (CST) Message-ID: <10479.65.102.128.233.1048603828.squirrel@fordparts.com> Date: Tue, 25 Mar 2003 08:50:28 -0600 (CST) Subject: Re: column label From: "Ryan" To: In-Reply-To: <3E7ED0E5.2060300@klaster.net> References: <10814.65.102.128.233.1048280104.squirrel@fordparts.com> <3E7ED0E5.2060300@klaster.net> X-Priority: 3 Importance: Normal Cc: X-Mailer: SquirrelMail (version 1.2.8) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-24.3 required=5.0 tests=BAYES_10,IN_REP_TO,MSG_ID_ADDED_BY_MTA_3,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/557 X-Sequence-Number: 12595 > Uz.ytkownik Ryan napisa?: >> Ok I have a query in a program that looks something like this >> >> select >> reference_number as foo, >> '(10,10)'::point <-> point(x,y) as distance >> from imagemap >> where >> index_number =3D '2322' and >> block_number =3D '140' >> order by distance >> limit 1; >> >> I wanted to add a clause in where 'and distance < 30' >> but according to the postgres manual it says I cannot do that for >> WHERE or HAVING clauses, instead use the real name. >> >> However dropping the 'as distance' from my query gives me a column >> name of '?column?' which happens to not be worth a dang thing. >> >> How can it be done? >> >> (I suddenly have a feeling its going to require a subselect) > Your feeling is 50% accurate. If you want to use subselect, throw "<10" > into this subselect, because you will have performance loss. > > You can also use whole function in where clause and order by: > select > reference_number as foo, > '(10,10)'::point <-> point(x,y) as distance > from imagemap > where > index_number =3D '2322' and > block_number =3D '140' > where '(10,10)'::point <-> point(x,y)<10 > order by '(10,10)'::point <-> point(x,y) > limit 1; > > BTW Did you try to use polygons in your image maps, or you have rather > point oriented web page than area oriented? > > Regards, > Tomasz Myrta Thats kind of a pain... I'd rather perform the calculation once and then do my order and where on the one value. Is there any reason why postgres does not recognize labels under WHERE? The reason I use points is because my customized web-based image mapping/ocr program can deal with points very aptly. Also with a distance based calc overlap is not really an issue as with polygons. The reason I am trying to limit the distance is simply to cut out clicking on far away parts of the image. Heck, I could check distance on the program side of things but I try and keep as much in SQL as possible. Ryan