X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E5C79475EFD for ; Mon, 24 Mar 2003 04:54:45 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 0B601475A8D for ; Mon, 24 Mar 2003 04:54:42 -0500 (EST) Received: from klaster.net (unknown [213.76.41.111]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 6C7316A21F; Mon, 24 Mar 2003 10:54:27 +0100 (CET) Message-ID: <3E7ED0E5.2060300@klaster.net> Date: Mon, 24 Mar 2003 10:33:25 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.3) Gecko/20030312 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Ryan Cc: pgsql-sql@postgresql.org Subject: Re: column label References: <10814.65.102.128.233.1048280104.squirrel@fordparts.com> In-Reply-To: <10814.65.102.128.233.1048280104.squirrel@fordparts.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-30.3 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,RCVD_IN_RFCI, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA 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/537 X-Sequence-Number: 12576 Uz.ytkownik Ryan napisa?: > Ok I have a query in a program that looks something like this >=20 > 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; >=20 > 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. >=20 > However dropping the 'as distance' from my query gives me a column name of > '?column?' which happens to not be worth a dang thing. >=20 > How can it be done? >=20 > (I suddenly have a feeling its going to require a subselect) Your feeling is 50% accurate. If you want to use subselect, throw "<10"=20 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=20 point oriented web page than area oriented? Regards, Tomasz Myrta