I have two tables:
ab_message
- user_id
- title
- content
- question
and ab_message_rating:
- id
- user_id
- message_id
- created_at
- updated_at
ab_message is in a OneToMany Relation with ab_message_rating. Every Entry in ab_message_rating has 1, 2 or 3 as rating value.
So i want to select in one query the Message an all related Tables Entries. The Key is, that i need in this query rating to be counted BY value.
For Example the Result schuld be:
Message abc has 5 entries of rating 1, 7 entries of rating 2, and 10
entries of rating 3
how to do that in a query? Something like Group By and A Join?
Sample Result: