重複するpost_titleが見つかった「new」レコードのフィールドpost-statusを「draft」に更新しようとしています。次の選択クエリは期待どおりに機能し、更新するレコードを表示します-
select a.* FROM wp_posts AS a INNER JOIN (SELECT Greater1.post_title, Titles.ID,
Greater1.MinID FROM (SELECT post_title, MIN(ID) AS 'MinID', MAX(ID) AS 'MaxID' FROM
wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY post_title
HAVING COUNT(post_title)>1) AS Greater1 LEFT JOIN (SELECT post_title, ID FROM
wp_posts) AS Titles ON Greater1.post_title = Titles.post_title WHERE ID > MinID) AS
b ON a.ID = b.ID WHERE a.ID = b.ID
ただし、次の更新クエリでは構文エラーが発生します。何か助けはありますか?
update a.wp_posts set a.post_status='draft' FROM wp_posts AS a INNER JOIN (SELECT
Greater1.post_title, Titles.ID, Greater1.MinID FROM (SELECT post_title, MIN(ID) AS
'MinID', MAX(ID) AS 'MaxID' FROM wp_posts WHERE post_type = 'post' AND post_status =
'publish' GROUP BY post_title HAVING COUNT(post_title)>1) AS Greater1 LEFT JOIN
(SELECT post_title, ID FROM wp_posts) AS Titles ON Greater1.post_title =
Titles.post_title WHERE ID > MinID) AS b ON a.ID = b.ID WHERE a.ID = b.ID
どうもありがとう。