I have two columns in table test as below. I want to update 2nd position in message with 'K' and 4th position as 'N' where id = 1 using Overlay function. I am able to update 2nd position as per below query but unable to find solution for 4th position.
Could you please provide me some guidance? Thank you.
Table test
id | message
------------
1 | ABCD
2 | PQRS
I wrote below query:
update test
set message = overlay(message placing 'K' from 2 for 1)
where id = 1
I got reference from Postgres String Functions and Operators