WordPress.org

Forums

Exports and Reports
[resolved] Exporting comments (6 posts)

  1. squareoak
    Member
    Posted 4 years ago #

    How is this done? Just as a test, this is what I have in the SQL Query:

    SELECT ID,post_title,post_name,post_date,post_content FROM wp_posts WHERE post_type='post'
    SELECT comment_ID FROM wp_comments WHERE comment_type='comment'

    Then in the fields below I've added field name as comment_ID and field label as Comment ID.

    When I run this report, it comes out empty.

  2. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 4 years ago #

    Are those two reports or one? You most likely need to either setup a JOIN in your query.

  3. squareoak
    Member
    Posted 4 years ago #

    Ah ok. Yeah those are two reports in one. Is there documentation somewhere where I can read-up on how to do that?

  4. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 4 years ago #

    This plugin currently requires MySQL knowledge which can be found online for the most part.

    Here's the simple change to your query to do what you want:

    SELECT c.comment_ID,p.ID,p.post_title,p.post_name,p.post_date,p.post_content FROM wp_posts AS p LEFT JOIN wp_comments AS c ON c.comment_post_ID = p.ID AND comment_type='comment' WHERE p.post_type='post'

  5. squareoak
    Member
    Posted 4 years ago #

    Cool. Thanks Scott!

  6. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 4 years ago #

    NP

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic