2

为什么这个sql显示mysql错误?

DELETE FROM wp_comments
JOIN wp_commentmeta ON wp_comments.comment_id =wp_commentmeta.comment_id 
AND wp_commentmeta.meta_key = 'somekey'                        
AND wp_comments.comment_post_ID = '1'

错误字符串

[Err] 1064 - You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version 
for the right syntax to use near 'INNER JOIN wp_commentmeta ON  
wp_comments.comment_id =wp_commentmeta.comment_id A' at line 2

请给我建议。

4

1 回答 1

6

join在语句中使用时,delete您必须指定要从哪些表中删除

DELETE c 
FROM wp_comments c
JOIN wp_commentmeta m ON c.comment_id = m.comment_id 
                      AND m.meta_key = 'somekey'                        
                      AND c.comment_post_ID = '1'
于 2013-06-25T18:18:22.203 回答