We help IT Professionals succeed at work.

SQL substring update

jjjjjjj
jjjjjjj asked
on
update library/file set substr(field1,13,3) = 'XYZ' where            
substr (field1,13,3)= 'ABC'  




My hope is that this SQL would update a portion of a field, but it does not work.  

Is there a way to update a portion of a field using SQL?

jjjjjjj
Comment
Watch Question

Developer
Commented:
Hi,

Assuming Field1 has a length of 50, I would Achieve the above as follows : -

update library/file set field1 = substr(field1,1,12) CONCAT 'XYZ' CONCAT  substr(field1,16,35)where substr(field1,13,3)= 'ABC'  




Author

Commented:
Too cool!!

Can you recommend any good books on how to write SQL code for the 400?

jjjjjjj
Peter PriceDeveloper

Commented:
No not really, I learned my SQL from Trial & Error & the  IBM AS/400 User Guide & Reference Manuals, but I am sure there must be some out there

Author

Commented:
Thanks for replying.