Little MySQL help needed: request from $wpdb->posts and $wpdb->comments
-
I am sure this is a very simple question, however not for me.
OK, I have 2 tables in MySQL (the standard WP tables):
I have 2 tables in MySQL:
Table 1: wp_posts
ID | post_date
———————————-
1 | 2006-01-02 18:05:01
2 | 2006-01-02 18:08:27Table 2: wp_comments
comment_post_ID | comment_ID
————————————————
1 | 101
1 | 102
2 | 103
2 | 104
1 | 105
2 | 106
2 | 107
2 | 108
2 | 109comment_ID (table wp_comments) = ID (table wp_posts).
I need the following result:
ID | *Number of comments*
1 3
2 6Which query do I need?
I have so far:
$query = ” SELECT ID, comment_post_ID, comment_ID FROM $tableposts, $tablecomments
WHERE comment_approved = ‘1’ AND post_status = ‘publish’
AND post_password=”
ORDER BY post_date DESC
LIMIT $limit “;Any help is appreciated.
Bob
- The topic ‘Little MySQL help needed: request from $wpdb->posts and $wpdb->comments’ is closed to new replies.