mysql query of comments – merge with another table?
-
I have no idea if anyone can help me here, but I’ve been trying for forever to figure this out and I can’t. I’m using the TwitterLink comments plugin to add an extra line to the comments form for additional information. On a certain page I’m trying to pull up the comment along with the data for the TwitterLink field. However it’s being stored in a separate table and I don’t know how to pull it in. My knowledge of mysql is basic at best, but I see a left outer join in the code here and I’m thinking maybe I need to add another one?
The table is named wptwitipid and the column I need is called twitd. I tried adding
LEFT OUTER JOIN $wpdb->wptwitipid ON ($wpdb->twitid.comment_post_ID = $wpdb->posts.id)
but I could be way off and it’s not working.If anyone has even a hint for me I’d really appreciate it!!
My code:
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,50) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' AND comment_post_ID = 90 ORDER BY comment_date_gmt DESC LIMIT 14"; $comments = $wpdb->get_results($sql); $comments = array_reverse($comments); $output = $pre_HTML;
- The topic ‘mysql query of comments – merge with another table?’ is closed to new replies.