From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Theodore Petrosky <tedpet5(at)yahoo(dot)com> |
Cc: | postgres SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: please help me with text cast to int .... |
Date: | 2004-07-11 17:06:06 |
Message-ID: | 20040711100337.Y854@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Sun, 11 Jul 2004, Theodore Petrosky wrote:
> I give up.. what don't I understand about casting and
> ints and text..
>
> i have a table jobinfo with:
>
> acode text,
> jobnumber text default
> nextval('public.jobinfo_seq'::text),
> jobtitle text
>
> I have about 3000 rows starting with jobnumber = 1000.
>
> SELECT jobnumber, jobtitle FROM jobinfo WHERE
> jobnumber >= 999 ORDER BY jobnumber ASC;
This is going to do a textual comparison, not an integer one.
So it's looking for jobnumbers greater than the string '999'.
If you want to treat jobnumber as an integer, CAST(jobnumber as integer)
>= 999 may be what you want. Note, however that it will fail if there are
any non-numeric jobnumber rows. In general, storing numbers in strings
that you want to act upon as numbers is a bad idea.
From | Date | Subject | |
---|---|---|---|
Next Message | Theodore Petrosky | 2004-07-11 18:52:16 | Re: please help me with text cast to int .... |
Previous Message | Phil Endecott | 2004-07-11 17:01:45 | Re: please help me with text cast to int .... |