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
Windows 7 Licensing
Excel Filter not listing in correct order
Why is appendOnly CRecordset readOnly
gunzip
Curious Sandbox folders in server 2008
How do I setup Windows 2003 Site and Services to force users to logon certain Domain Controllers
Datagrid selection change on mouseove
lotus notes for windows 98
Windows Update returns Error 403 forbidden
Windows 7 Backup