Casting int to bool with join...

From: Randall Skelton <skelton(at)brutus(dot)uwaterloo(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Casting int to bool with join...
Date: 2004-04-02 23:05:29
Message-ID: 3BF5CD7C-84FA-11D8-BEF7-000393C92230@brutus.uwaterloo.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am trying to update rows in a new table and re-cast to boolean at the
same time. I am absolutely certain that the integers are 0 or 1. Is
there a one line way to do this?

UPDATE app_id_800 SET cal_byte_w_err = cal_byte_w_err.value::boolean
FROM cal_byte_w_err
WHERE app_id_800.timestamp BETWEEN '2004-01-01 00:00:00' AND
'2004-01-01 00:00:05'
AND app_id_800.timestamp = cal_byte_w_err.timestamp;

Many thanks... I've spent way too long trying to figure this out :(

Cheers,
Randall

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-04-02 23:06:12 Re: [GENERAL] Large DB
Previous Message wespvp 2004-04-02 22:09:57 Re: Compound keys and foreign constraints