I have a mysql DB with two tables:
- messages
- message_answers
I’d like to fetch all messages and the number of answers for each of them, like:
- first message (10 answers)
- second message (5 answers)
Is it possible with a single sql query ?
I tried a query and a subquery for the count, but I don’t know how to have the current id from the main query to make the “WHERE” restriction on the subquery (like: “message_answers.message_id = messages.id”).
Thank you,
Sébastien
1 Answer