On Dec 20, 2004, at 9:05, A Gilmore wrote:
> Id like my application to do something like this :
> SELECT now() AS currentTime WHERE currentTime < '$timestamp';
> So if it returns a row Id know $timestamp is not in the past. However
> when you run this it simply says 'ERROR: column "currentTime" does
> not exist'.
AFAIK, SELECT clause aliases are not available to any other part of the
query: it's looking for a column called currentTime, but there isn't
one in the FROM clause tables. Then again, you don't even have a FROM
clause. :) In general, it's best to show the exact query you're trying
and the error messages you're getting--and if possible, reduce it to a
test case that still exhibits the problem.
You probably want something like:
SELECT foo FROM bar WHERE current_timestamp < baz;
( current_timestamp is the SQL standard spelling of the PostgreSQL
alternative now(). )
Also note that all identifiers are converted to lowercase unless
double-quoted. PostgreSQL sees currentTime as currenttime.
Hope this helps.
grzm myrealbox com
In response to
pgsql-novice by date
|Next:||From: A Gilmore||Date: 2004-12-20 02:34:45|
|Subject: Re: Querying now()|
|Previous:||From: Tom Lane||Date: 2004-12-20 00:46:56|
|Subject: Re: Querying now() |