Reputation: 8783
Given the following table, how can write a MySQL query to display threaded comments in a single page?
Table structure:
Thank you.
Upvotes: 0
Views: 4397
Reputation: 563
It will work!
http://www.jongales.com/blog/2009/01/27/php-class-for-threaded-comments/
Upvotes: 3
Reputation: 3519
Depending on how deep you want to go ... but here is a 1-thread example to do with 1 query
SELECT * FROM `comment` a LEFT JOIN `comment` b ON a.comment_id = b.comment_id WHERE a.comment_parent = 0
then use php to select wether the parent comment changes and display that.
but it would likely be better to do this over multiple queries for speed. you would need to do some benchmarks to be sure
Upvotes: 0
Reputation: 1731
Select comment_content from table where comment_parent != 0;
Then use PHP to display the results however you want.
Upvotes: 0