So.. a couple of days later I figured it out myself.
Fortunately there was another table holding all the ids I needed in order to make the updates I was looking for.
So in addition to
table_1_user
table_2_user
table_3_user
There was a table holding the ids:
TABLE users
user_id | user_name | ...
1 max
2 justin
... ...
So in a first step I had to create a temporary table:
CREATE TEMPORARY TABLE temp
SELECT user_id FROM users;
Next I had to create a procedure in order to be able to use while loops:
DELIMITER $$
DROP PROCEDURE IF EXISTS Update_User_URLS;
CREATE PROCEDURE Update_User_URLS()
BEGIN
...
END $$
DELIMITER ;
CALL Update_User_URLS();
Then I had to add the needed while loop selecting a user_id from the temporary table. At the end of the loop this user_id had to be removed from the temp table:
DELIMITER $$
DROP PROCEDURE IF EXISTS Update_User_URLS;
CREATE PROCEDURE Update_User_URLS()
BEGIN
WHILE (SELECT COUNT(*) FROM temp) > 0 DO
SELECT @id := user_id FROM temp LIMIT 1;
...
DELETE FROM temp WHERE user_id = @id;
END WHILE;
END $$
DELIMITER ;
CALL Update_User_URLS();
Within the while loop I had to set a variable as concatenated table name and use PREPARE for my designated query as well as EXECUTE in order to fire it.
DELIMITER $$
DROP PROCEDURE IF EXISTS Update_User_URLS;
CREATE PROCEDURE Update_User_URLS()
BEGIN
WHILE (SELECT COUNT(*) FROM temp) > 0 DO
SELECT @id := user_id FROM temp LIMIT 1;
SET @table = concat('table_', @id, '_user');
SET @query = concat('UPDATE ', @table, 'SET user_url = replace(user_url, '"example.com"', '"anotherexample.com"')')
PREPARE statement from @query;
EXECUTE statement;
DELETE FROM temp WHERE user_id = @id;
END WHILE;
END $$
DELIMITER ;
CALL Update_User_URLS();
And it worked for me!