Hi i have my query I want to join 4 tables here is my code
SELECT c.name, u.username, u.thumbnail, q.question,
a.answer, a.uid, COALESCE( COUNT( a.qid ) , 0 ) AS cnt
FROM question_category c
INNER JOIN question q ON q.cid = c.id
LEFT JOIN answer a ON a.qid = q.id
LEFT JOIN hmuser u ON u.id = q.uid
GROUP BY c.name
ORDER BY cnt DESC
LIMIT 5
I want to display the category of question, name who ask question,the thumbnail who ask question,the question it self, how many answer does the question have, the answers and who answer on the question How to do this on mysql?
here are my tables and fields
question_category
id name
question
id uid cid question added
answer
id uid qid answer added
hmuser
id username thumbnail
I want my output to be like this
question = How are you? =posted by: user
(3) answer's = I'm fine = answered by: user2
category
q1 3
a1
a2
a3
q2 1
a1
category
q1 4
a1
a2
a3
a4
q2 2
a1
a2
any idea? Any help are very much appreciated ! Thank you!