I'm using this query to select certain row from the wp_postmeta table
SELECT *
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.meta_value
WHERE (wp.ID IS NULL) AND (pm.meta_key = '_wpcf_belongs_books_id')
and it's working fine but when I try to use the DELETE
DELETE
FROM wp_postmeta pm
LEFT JOIN fddb_wp_posts wp ON wp.ID = pm.meta_value
WHERE (wp.ID IS NULL) AND (pm.meta_key = '_wpcf_belongs_books_id')
it returns an error saying
#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 'pm LEFT JOIN fddb_wp_posts wp ON wp.ID = pm.meta_value WHERE (wp.ID IS NULL) AND' at line 2
Any suggestion on how to make it work?
If you have a delete statement with more than one table you need to name the tables you want to delete from. Do that right after the delete
keyword
DELETE pm
FROM fddb_wp_postmeta pm ...