Re: How to select text field as interger

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to select text field as interger
Дата
Msg-id 25124.1277849228@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: How to select text field as interger  (Tim Landscheidt <tim@tim-landscheidt.de>)
Ответы Re: How to select text field as interger  (silly sad <sad@bankir.ru>)
Список 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 по дате отправления:

Предыдущее
От: Tim Landscheidt
Дата:
Сообщение: Re: How to select text field as interger
Следующее
От: silly sad
Дата:
Сообщение: Re: How to select text field as interger