Re: Cast character to boolean

From: "Edmund(dot)Bacon" <ebacon(at)shaw(dot)ca>
To: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>
Subject: Re: Cast character to boolean
Date: 2008-03-21 17:53:34
Message-ID: 47E3F61E.4000609@shaw.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Roberts, Jon wrote:
> A case statement will work just fine:
>
> select case when sub.col1 = 'y' then true else false end as
> col1_boolean, sub.col1 from (select cast('y' as varchar) as col1) sub

Be aware of the danger here. What happens if col1 is NULL?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Webb Sprague 2008-03-21 18:07:21 Re: Table size
Previous Message Justin 2008-03-21 17:47:38 Re: MySQL to Postgres question