删除加入

时间:2015-01-26 11:56:49

标签: mysql join sql-delete

我已经搜索了答案,但找不到我做错了什么,我一直收到错误;

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')

有人能告诉我我做错了吗?

1 个答案:

答案 0 :(得分:0)

您需要在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'