Sunday, September 6, 2026

Update Column values using REPLACE function in MySQL

Following SQLs commands can be used to replace the content of the column using new values rather than writing new scripts to update values.

SELECT pdf_location,

       REPLACE(pdf_location, '/2026/08/', '/2026/09/') AS new_pdf_location

FROM cib_pdf_bill

WHERE pdf_location LIKE '/c01/cipdf/2026/08/%' and account_no = '33700503';


UPDATE cib_pdf_bill

SET pdf_location = REPLACE(pdf_location, '/2026/25/', '/2026/08/')

WHERE pdf_location LIKE '/c01/cipdf/2026/25/%' and account_no = '33700503';