I'm trying to count my comments and there replies but I can't seem to get it right.
Here is my query so far.
SELECT posts_comments.*, users.*
(SELECT COUNT(*)
FROM posts_comments
WHERE parent_comment_id >= 1)
FROM posts_comments
LEFT JOIN users
ON posts_comments.user_id = users.user_id
WHERE post_id = '" . $post_id . "'
AND parent_comment_id = 0
LIMIT $start, $display
And here is my MySQL table.
CREATE TABLE posts_comments (
comment_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_comment_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
post_id INT UNSIGNED NOT NULL,
comment TEXT NOT NULL,
PRIMARY KEY (id),
);
Display Output.
COMMENT 1
comment 2
comment 3
COMMENT 4
COMMENT 5