theEclipse
Programmer
I am going to try and explain this without dumping my whole database into this little box and hoping you all read it ;-). The design should be normal enough. If needed, I can post the definitions.
I am setting up a multi-user CMS:
a table for content, a table for users, and a table for comments on content. Special concern: both Content and comments tables have a [tt]deleted[/tt] column for the purpose of data retention
For a site-map page, I am listing every content entry with its author and number of comments, among other things.:
I have tried all manner of where clauses and groupings in order to get the [tt]commentCount[/tt] field to only count the number of comments which are not deleted.
The solution is probably right in front of me...but I have been staring at this problem for about two weeks and made no progress.
Any ideas?
Thanks for reading.
Robert Carpenter
Remember....eternity is much longer than this ~80 years we will spend roaming this earth.
ô¿ô
I am setting up a multi-user CMS:
a table for content, a table for users, and a table for comments on content. Special concern: both Content and comments tables have a [tt]deleted[/tt] column for the purpose of data retention
For a site-map page, I am listing every content entry with its author and number of comments, among other things.:
Code:
SELECT
COUNT(comments.id) AS commentCount,
content.id,
content.title,
UNIX_TIMESTAMP(content.date) as date,
content.text,
users.name AS author
FROM content
LEFT JOIN comments ON comments.contentid=content.uid
JOIN users ON content.author=users.id
WHERE(content.deleted=false)
GROUP BY content.id
ORDER BY content.date DESC;
END;
I have tried all manner of where clauses and groupings in order to get the [tt]commentCount[/tt] field to only count the number of comments which are not deleted.
The solution is probably right in front of me...but I have been staring at this problem for about two weeks and made no progress.
Any ideas?
Thanks for reading.
Robert Carpenter
Remember....eternity is much longer than this ~80 years we will spend roaming this earth.
ô¿ô