为什么这个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
请告诉我。
答案 0 :(得分: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'