Re: How to select text field as interger - Mailing list pgsql-sql

From Tom Lane
Subject Re: How to select text field as interger
Date
Msg-id 25124.1277849228@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to select text field as interger  (Tim Landscheidt <tim@tim-landscheidt.de>)
Responses Re: How to select text field as interger  (silly sad <sad@bankir.ru>)
List pgsql-sql
Tim Landscheidt <tim@tim-landscheidt.de> writes:
> Jerrel Kemper <jerrel@s-wise.nl> wrote:
>> How can I have the same result set as above

>> Name
>> 001
>> 01
>> 1

>> with the name field defined as character varying.

> Ah! Your excentric formatting and the reference to "serial"
> had me wondering if the indentation had any meaning. You can
> select the rows where the "Name" field is numerically equal
> to 1 by casting it to an integer and then comparing it to 1,
> i. e.:

> | SELECT Name FROM Test WHERE Name::INT = 1;

But note that this is going to throw an error if there are any table
rows where the name field *doesn't* contain a valid integer.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tim Landscheidt
Date:
Subject: Re: How to select text field as interger
Next
From: silly sad
Date:
Subject: Re: How to select text field as interger