我试图使用left join删除帖子类型的帖子,但出现以下错误:
您的SQL语法有错误;查看与MySQL服务器版本相对应的手册,以了解“LIMIT 1”附近要使用的正确语法
代码:
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("DELETE posts,pt,pm
FROM wp_posts posts
LEFT JOIN wp_term_relationships pt ON ( pt.object_id = posts.ID AND pt.term_taxonomy_id = %d)
LEFT JOIN wp_postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s
LIMIT %d
",
456,
\'listing\',
1
)
);