Thread: Only updating part of a column

Only updating part of a column

From
Dave Smith
Date:
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';

This does not work. Is this possible? Or am I looking at this the wrong
way?

--
Dave Smith
Candata Systems Ltd.
(416) 493-9020
dave@candata.com

Re: Only updating part of a column

From
Thomas Lockhart
Date:
> 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