By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE wppp_term_relationships (
`object_id` INTEGER,
`term_taxonomy_id` INTEGER
);
INSERT INTO wppp_term_relationships
(`object_id`, `term_taxonomy_id`)
VALUES
('1234', '2010'),
('2344', '30453');
Records: 2 Duplicates: 0 Warnings: 0
CREATE TABLE wppp_terms (
`term_id` INTEGER,
`name` VARCHAR(6)
);
INSERT INTO wppp_terms
(`term_id`, `name`)
VALUES
('30453', '2010'),
('2010', 'toy');
Records: 2 Duplicates: 0 Warnings: 0
UPDATE wppp_term_relationships tr
JOIN wppp_terms t ON tr.term_taxonomy_id = t.term_id
SET tr.term_taxonomy_id = t.name
WHERE t.name REGEXP '^[0-9]*$';
Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM wppp_term_relationships;
object_id | term_taxonomy_id |
---|---|
1234 | 2010 |
2344 | 2010 |