I have 2 mysql tables (Version Minor to MySql 8) in a simple chat app
Chat
| id_chat | chat_name | 
|---|---|
| 1 | My first chat | 
| 2 | My Second Chat | 
And Chat_Message
| id_chat_message | id_chat | message | date | 
|---|---|---|---|
| 1 | 1 | How | 03/Mar/2021 | 
| 2 | 1 | Are you | 04/Mar/2021 | 
| 3 | 2 | This | 05/Mar/2021 | 
| 4 | 2 | Is other | 06/Mar/2021 | 
How can I make a Query if I want to retrieve the last message for every chat?
The resultset should be
| id_chat | chat_name | last_message | last_message_date | 
|---|---|---|---|
| 1 | My first chat | Are you | 04/Mar/2021 | 
| 2 | My Second Chat | Is other | 06/Mar/2021 | 
Thanks
 
    