I had been not successful attempting to migrate a bbPress 1. instalation towards the new bbPress 2. wordpress plugin on my small WordPress, which made a significant mess on my small
I solved that by removing every posts who had been transporting the values
reply towards the
post_type column, which was good.
However I observed the
wp_postmeta appears impacted by plenty of records refering to posts that I have erased. Both tables possess the
Now you ask ,: which SQL command I personally use to remove the values on
wp_postmeta referencing lines who aren't any longer on
wp_posts? I understand it's some type of join which i should use however i aren't seeing how it might be to search for something who isn't there and remove it.
PS: And what's going on with WordPress tables not keeping referential integrity? I am confident you can remove something instantly from
wp_postmeta when removing something related on
wp_posts. Oh well…
I understand it's some type of join which i should use however i aren't seeing how it might be to search for something who isn't there and remove it.
Yes, you need to use outer joins.
PS: And what's going on with WordPress tables not keeping referential integrity?
Lots of more recent programs are now using entity frameworks and do not clearly enforce referential integrity, just associations. Atlassian JIRA, for instance, does not enforce referential integrity.
an over-all method to by hand remove rows from table a which have no match in table b is:
DELETE FROM table_a WHERE some_id NOT IN (SELECT some_id FROM table_b);
it isn't really the best method to perform a mass remove (joins could most likely get it done faster), however i usually should you prefer a subselect in this case, it's simpler to know and for that reason cuts down on the FUBAR probability (you won't want to accidentally remove rows in table_b etc)
so inside your situation you can most likely make a move such as this:
SELECT * FROM wp_postmeta WHERE post_id NOT IN (SELECT post_id FROM wp_posts);
if you're sure, fundamental essentials rows you need to remove, replace Choose * with Remove:
DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT post_id FROM wp_posts);