From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
---|---|
To: | A Gilmore <agilmore(at)shaw(dot)ca> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Querying now() |
Date: | 2004-12-20 00:57:22 |
Message-ID: | 1B15B3D8-5222-11D9-93E5-000A95C88220@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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.
Michael Glaesemann
grzm myrealbox com
From | Date | Subject | |
---|---|---|---|
Next Message | A Gilmore | 2004-12-20 02:34:45 | Re: Querying now() |
Previous Message | Tom Lane | 2004-12-20 00:46:56 | Re: Querying now() |