Re: Only updating part of a column

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Dave Smith <dave(at)candata(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Only updating part of a column
Date: 2000-07-25 05:44:52
Message-ID: 397D2954.9818573F@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I would like to know if I can update part of a column. ie
> update myfile set substr(direct_key,1,10)='1234567890' where
> substr(direct_key,1,10)='0987654321';

update myfile
set direct_key = '1234567890' || substring(direct_key from 11)
where substring(direct_key from 1 for 10) = '0987654321';

Note that you can use substr() also...

- Thomas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message jprem 2000-07-25 06:21:43 nested transactions
Previous Message Tom Lane 2000-07-25 05:44:37 Re: 4 billion record limit?