pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Theodore Petrosky <tedpet5@yahoo.com>
Cc: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: please help me with text cast to int ....
Date: Sun, 11 Jul 2004 10:06:06 -0700 (PDT)
Message-ID: <20040711100337.Y854@megazone.bigpanda.com> (raw)
In-Reply-To: <20040711162246.34618.qmail@web41004.mail.yahoo.com>
References: <20040711162246.34618.qmail@web41004.mail.yahoo.com>


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.




view thread (4+ messages)  latest in thread

Message-ID: <20040711100337.Y854@megazone.bigpanda.com>
Permalink:  ../20040711100337.Y854@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20040711100337.Y854@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, tedpet5@yahoo.com
  Subject: Re: please help me with text cast to int ....
  In-Reply-To: <20040711100337.Y854@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox