Mysql 使用内部联接更新sql数据
我想将wordpress数据库中的帖子状态从草稿更改为垃圾,以便重复具有相同帖子标题的帖子,我使用此sql查询Mysql 使用内部联接更新sql数据,mysql,sql,database,wordpress,syntax,Mysql,Sql,Database,Wordpress,Syntax,我想将wordpress数据库中的帖子状态从草稿更改为垃圾,以便重复具有相同帖子标题的帖子,我使用此sql查询 UPDATE a.post_status SET `post_status` = 'trash' FROM wp_posts AS a INNER JOIN ( SELECT post_title, MIN( id ) AS min_id FROM wp_posts WHER
UPDATE a.post_status SET `post_status` = 'trash'
FROM wp_posts AS a
INNER JOIN (
SELECT post_title, MIN( id ) AS min_id
FROM wp_posts
WHERE post_type = 'post'
AND post_status = 'draft'
GROUP BY post_title
HAVING COUNT( * ) > 1
) AS b ON b.post_title = a.post_title
AND b.min_id <> a.id
AND a.post_type = 'post'
AND a.post_status = 'draft'
此查询的正确语法是什么?MySQL中的正确语法不使用FROM:
请注意,我还将表格别名从无意义的字母改为更有意义的缩写。感谢Gordon在这个语法中给出的答案。我发现其他错误是错误代码:1146表格“a.post_status”没有exist@hassanii现在试试。@草莓。非常感谢。
Error Code: 1064
Erreur de syntaxe près de 'FROM wp_posts AS a
INNER JOIN (
SELECT post_title, MIN( id ) AS min_id
' à la ligne 2
UPDATE post_status ps INNER JOIN
(SELECT post_title, MIN( id ) AS min_id
FROM wp_posts
WHERE post_type = 'post' AND
post_status = 'draft'
GROUP BY post_title
HAVING COUNT( * ) > 1
) p
ON p.post_title = ps.post_title AND
p.min_id <> ps.id AND
ps.post_type = 'post' AND
ps.post_status = 'draft'
SET ps.post_status = 'trash';