MySQL Forums
Forum List  »  Newbie

Group by fk in two tables
Posted by: Pietje van der Pukje
Date: November 16, 2023 03:12AM

I would like to implement a query that returns the following result. Could anyone help with this?

Table: tickets
*Id | customer
1 | 1
2 | 1
3 | 2
4 | 3

Table: ticket_messages
id | *ticket_id | message
1 | 1 | message
2 | 1 | message
3. | 2 | message


Result
customer. | number_of_tickets | number_of_ticket_messages
1 | 2 | 2
2 | 1 | 1
3 | 1 | 0

Options: ReplyQuote


Subject
Written By
Posted
Group by fk in two tables
November 16, 2023 03:12AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.