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

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -