column label

From: "Ryan" <pgsql-sql(at)seahat(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: column label
Date: 2003-03-21 20:55:04
Message-ID: 10814.65.102.128.233.1048280104.squirrel@fordparts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 = '2322' and
block_number = '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)

Ryan

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Franco Bruno Borghesi 2003-03-21 22:10:01 function prepared plan
Previous Message Stephan Szabo 2003-03-21 20:13:33 Re: