php - MySQL make count not return anything if no rows are found -



php - MySQL make count not return anything if no rows are found -

i'm trying utilize count in mysql query count amount of rows matching column, , query working, when select query count beingness used in returns no rows, count value still returns 0 query homecoming empty row except count column has 0.

this query:

select forum_threads_forums.id, forum_threads.title, forum_threads.description, forum_threads.views, count(distinct forum_posts_threads.post_id) post_count, users.id user_id, users.username user_username forum_threads inner bring together forum_threads_forums on forum_threads.id=forum_threads_forums.thread_id , forum_threads_forums.forum_id=:forum_id left outer bring together forum_posts_threads on forum_posts_threads.thread_id=forum_threads_forums.thread_id inner bring together users on forum_threads.user_id=users.id

when select query doesn't homecoming rows, count still does. result such this:

id title description views post_count user_id user_username 0

i homecoming nil @ can reliably count results php.

does have thought on how accomplish this? i'm lost.

thanks help in advance.

add:

having post_count > 0

to end of query.

it homecoming 1 row if there matches, , post_count contain number of distinct posts, or 0 rows if there no matches.

php mysql pdo

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -