php - I have two tables Questions and answers, I would like to display all questions with details of their answers. Eg. 23(views) 12 (answers) -


this doesn't show questions without answers

select    m.id, m.j_surname,    q.id qid, q.qus_view_count, q.qus_owner, q.qus_title, q.qus_description,   q.qus_createddate,    count(a.qus_id) ans_count,    a.qus_id jt_questions q  left join jt_members m on m.id = q.qus_owner  left join jt_answers on q.id = a.qus_id  group a.qus_id  order q.qus_createddate desc  limit $offset, $recordsperpage; 

try group q.id not group a.qus_id

for unanswered questions a.qus_id have value of null


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -