By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table wp_terms(slug varchar(20))
insert into wp_terms values
('2017'),
('hello'),
('a string'),
('2003'),
('a1995value'),
('words'),
('2005'),
('2004stuff'),
('category2018'),
('string2004')
select * from wp_terms
slug |
---|
2017 |
hello |
a string |
2003 |
a1995value |
words |
2005 |
2004stuff |
category2018 |
string2004 |
UPDATE wp_terms
SET slug = CONCAT(LEFT(slug, LENGTH(slug) - 4), RIGHT(slug, 4) - 1)
WHERE slug RLIKE '[[:digit:]]{4}$' AND RIGHT(slug, 4) > 2008
select * from wp_terms
slug |
---|
2016 |
hello |
a string |
2003 |
a1995value |
words |
2005 |
2004stuff |
category2017 |
string2004 |