Here is an example how to replace missing author ids in bulk by running a SQL script in phpMyAdmin.
The first statement sets the user id of the new author. The CREATE statement creates a temporary table. The subsequent query finds all the articles where the author details cannot be found and adds the article ids to a temporary table, which is then accessed to update those articles with the new author.
The same pattern can be used to update the column 'modified_by'. Replace 'ep28r' with your own table prefix.
The first statement sets the user id of the new author. The CREATE statement creates a temporary table. The subsequent query finds all the articles where the author details cannot be found and adds the article ids to a temporary table, which is then accessed to update those articles with the new author.
The same pattern can be used to update the column 'modified_by'. Replace 'ep28r' with your own table prefix.
Code:
SET @author = 123;DROP TEMPORARY TABLE IF EXISTS deleted_users;CREATE TEMPORARY TABLE deleted_users (`id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`))SELECT c.id FROM ep28r_content cLEFT JOIN ep28r_users u ON c.created_by = u.idWHERE u.id IS NULL;UPDATE ep28r_content c SET c.created_by = @authorWHERE c.id IN(SELECT d.id FROM deleted_users d);
Statistics: Posted by toivo — Thu Nov 14, 2024 1:34 am