I have the following two tables
User (Email(PK), Nombre, Rol)
and Message (Id (Pk), IDSend (FK), IDDest(FK), Mensaje, Status, Fecha)
I need to return the Email, the Name, the message and the Status of the last message of each user registered in the database. Any ideas that you can give me?
This is what I have
Select IDSend, MAX(Fecha) as Date, Status, Mensaje
FROM message group by IDSend HAVING IDSend in (Select Email from user)