Re: please help me with text cast to int ....
| От | Stephan Szabo |
|---|---|
| Тема | Re: please help me with text cast to int .... |
| Дата | |
| Msg-id | 20040711100337.Y854@megazone.bigpanda.com обсуждение исходный текст |
| Ответ на | please help me with text cast to int .... (Theodore Petrosky <tedpet5@yahoo.com>) |
| Ответы |
Re: please help me with text cast to int ....
|
| Список | 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.
В списке pgsql-sql по дате отправления: