The REPLACE function should be sufficient to solve the problem.
Test table:
CREATE TABLE test (text varchar(100)); INSERT INTO test (text) VALUES ('pxq'); INSERT INTO test (text) VALUES ('static-text-here/pxq'); INSERT INTO test (text) VALUES ('static-text-here/1abcdefgpxq'); INSERT INTO test (text) VALUES ('static-text-here/1abcdefg1abcdefgpxq');
Query:
SELECT text, REPLACE(text, '1abcdefg1abcdefg', '1abcdefg') AS text2 FROM test;
Result:
TEXT TEXT2 pxq pxq static-text-here/pxq static-text-here/pxq static-text-here/1abcdefgpxq static-text-here/1abcdefgpxq static-text-here/1abcdefg1abcdefgpxq static-text-here/1abcdefgpxq
The AFAIK REPLACE function is not available in the SQL99 standard, but most DBMSs support it. I tested it here and it works with MySQL, PostgreSQL, SQLite, Oracle and MS SQL Server.
source share