Php (根据您的需要) SELECT p.post_id, p.title, c.comment_body FROM posts p LEFT JOIN comments c ON c.parent_id = p.post_id while($row = my
(根据您的需要)Php (根据您的需要) SELECT p.post_id, p.title, c.comment_body FROM posts p LEFT JOIN comments c ON c.parent_id = p.post_id while($row = my,php,mysql,join,Php,Mysql,Join,(根据您的需要) SELECT p.post_id, p.title, c.comment_body FROM posts p LEFT JOIN comments c ON c.parent_id = p.post_id while($row = mysql_fetch_array($result)) { echo $row['title'] . " " . $row['comment_body']; echo "<br />"; } SELECT p.post
SELECT p.post_id, p.title, c.comment_body
FROM posts p
LEFT JOIN comments c
ON c.parent_id = p.post_id
while($row = mysql_fetch_array($result))
{
echo $row['title'] . " " . $row['comment_body'];
echo "<br />";
}
SELECT p.post_id, p.title, GROUP_CONCAT(c.comment_body)
FROM posts
LEFT JOIN comments c ON c.parent_id = p.post_id
GROUP BY p.post_id
SELECT p.post_id, p.title, GROUP_CONCAT(c.comment_body), count(*) as coment_cnt
FROM
posts p
LEFT JOIN comments c ON (p.post_id = c.parent_id)
GROUP BY
p.post_id
$lastpostid=false;
while ($r=mysql_fetch_assoc($result)) {
if ($r['post_id']!=$lastpost) {
print "Post: " . $r['title'] . "<br />\n";
$comment_id=1;
$lastpost=$r['post_id'];
}
print "Comment # $comment_id : " . $r['comment_body'] . "<br />\n";
$comment_id++;
}