Forums

Custom query help (1 post)

  1. sunscream
    Member
    Posted 2 years ago #

    Wondering if anyone can help with a custom query of mine. It's a recent comments query. It basically gets the recent comments and groups them by posts so it doesn't show duplicate posts when I print it in a list. The problem is the query has been overloading mysql on my server. Can anyone see a better more efficient way to do it?

    $request = "SELECT ID, comment_ID, comment_content, comment_date, comment_author, comment_author_url, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE post_status IN ('publish','static') ";
    
    $request .= "AND comment_approved = '1' GROUP BY $wpdb->posts.ID ORDER BY comment_date DESC LIMIT $number";

Topic Closed

This topic has been closed to new replies.

About this Topic