I have 2 tables :
- review (including content_type_id , object_id )
- comments (including content_type_id , object_id )
The combination of “content_type_id and object_id” uniquely defines an entity (like article etc)
Now i want to write a single SQL Query to :
“list all the articles with their ‘review_count’ and ‘comment_count’ “.
I mean in final result , what i want is :
content_type_id | object_id | review_count | comment_count
How can i acheive this..??
(Edited after question changed and I found a data-bug)
Try this one:
It does not use a central table (formerly called
article). This means, that items without any comment and without any review will not show up in the result. Items where at least one comment or one review is there will show up.