MySQL select post and comment count relative to comment count -
i'm trying select
posts comment count
select id,title ,(select count(*) ci_comments (post_id = p.id)) comment_count ci_posts p type='post' , active=1 order comment_count desc , date_modified desc limit 6
this works
but need filter comment_count > 10
:
select id,title ,(select count(*) ci_comments (post_id = p.id)) comment_count ci_posts p type='post' , active=1 , comment_count > 10 order comment_count desc , date_modified desc limit 6
result : unknown column 'comment_count' in 'where clause'
so solution ?
try having .. having evaul result of query
select id,title ,(select count(*) ci_comments (post_id = p.id)) comment_count ci_posts p type='post' , active=1 having comment_count >10 order comment_count desc , date_modified desc limit 6
Comments
Post a Comment