0

I am migrating a news aggregation WP site to a commercial service. We currently have over 14,000 posts on it.

We want to save the current database and reuse it under a different domain name for historical purposes.

Once we move to the new site we want to trim the WP database of all posts and related tables that are older than 01.01.2013

I know how to do a simple select where delete query.

But WP forum mods have told me that I should do an inner-join on the following tables to ensure I get everything cleaned up:

wp_postmeta

wp_term_relationships

wp_comments

wp_commentmeta

I am not familiar with inner-join. Can someone help me with this?

1
  • yes you should left join them then eventually in where clause you can use the datetime when it is post eg. WHERE datetime > 01.01.2013 Commented Mar 22, 2013 at 2:03

1 Answer 1

1

Not completely understanding the table structures involved, an INNER JOIN will join one table to another and return the records that match based on a certain criteria (usually joining two fields together such as a primary key and a foreign key).

To delete records from one table where some or all are in another table, the following syntax would be used:

DELETE TableName
FROM TableName
INNER JOIN AnotherTable ON TableName.id = AnotherTable.id

Here's a good visual representation of JOINS.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.