Microsoft
Software
Hardware
Network
Question : Sql query
I have 2 tables.
tblContacts
ID
Name
LastMessageDate
tblMessages
ID
Message
ContactRef
RecvdDate
Each contact may have many messages. I just added the LastMessageDate field to the Contact table. I want to update it with the most recently recieved message for each contact, as recorded in the tblMessage table.
How can I write a query to do this?
Answer : Sql query
update tblContacts
set LastMessageDate = M.Lmd
from tblContacts C
inner join (select Id, max(LastMessageDate) as LMD from tblMessages group by Id) M
on c.Id = M.Id
Random Solutions
Control Panel Icons - Windows XP
DropDownBox Null Value
Sharepoint - How to view version history of all items in a list on a single page
How to read a stack trace in visual studio
Response.Redirect is not working properly in the server?
Windows Server 2003
General MS Graph problems in Access 2007
ORA-12514 TNS:listener does not currently know of service requested in connect (yet agian?)
Reporting service login prompts pops up when deploying reprots on SSRS 2008
Drop Down List and Back Button on Browser - Losing state?