mysql - How to count comments while selection posts -


i have 2 tables

tb_posts id,title,description

tb_comments id,post_id,comment

i want select posts count of comments.

how write single query it?

i think should do:

select tb_posts.id, tb_posts.title, tb_posts.description       tb_posts inner join tb_comments        on  tb_posts.id = tb_comments.post_id group tb_posts.id, tb_posts.title, tb_posts.description  having count(*) > some_threshold_value 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -