删除并加入
Delete with join
我搜索了答案,但找不到我做错了什么,我一直在出错;
DELETE
FROM kp_postmeta
JOIN kp_posts
ON kp_postmeta.post_id = kp_posts.ID
WHERE (kp_posts.post_type = 'flamingo_inbound' AND kp_posts.post_date < '2014-12-31')
谁能告诉我哪里做错了?
您需要在 delete
之后指定要从哪些表中删除。如果从两者来看,它看起来像这样
DELETE kp_postmeta, kp_posts
FROM kp_postmeta
JOIN kp_posts ON kp_postmeta.post_id = kp_posts.ID
WHERE kp_posts.post_type = 'flamingo_inbound'
AND kp_posts.post_date < '2014-12-31'
我搜索了答案,但找不到我做错了什么,我一直在出错;
DELETE
FROM kp_postmeta
JOIN kp_posts
ON kp_postmeta.post_id = kp_posts.ID
WHERE (kp_posts.post_type = 'flamingo_inbound' AND kp_posts.post_date < '2014-12-31')
谁能告诉我哪里做错了?
您需要在 delete
之后指定要从哪些表中删除。如果从两者来看,它看起来像这样
DELETE kp_postmeta, kp_posts
FROM kp_postmeta
JOIN kp_posts ON kp_postmeta.post_id = kp_posts.ID
WHERE kp_posts.post_type = 'flamingo_inbound'
AND kp_posts.post_date < '2014-12-31'