我想数我的意见,并在那里答复,但我似乎无法得到它的权利。MySQL查询计数问题
这是我的查询到目前为止。
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
这里是我的MySQL表。
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),
);
显示输出。
COMMENT 1
comment 2
comment 3
COMMENT 4
COMMENT 5
你能告诉我们一些样本期望的输出吗? – 2010-09-17 04:08:06
不是它是一回事吗? – FOXvsNBC 2010-09-17 04:16:45