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
Visio 2007: Can't access UML diagram properties
Problem with vista update The error code is 80073712
Cisco PIX 5505 - 2 webserves
Query: order within group
Hyper-V Licensing
Silverlight Default.html does not animate
Login box keeps coming up in Outlook 2007 using Exchange 2007
changing authentication mode and adding SA user for SQL Express 2005
Usa an Acrobat PDF as a Document Library Content Type Document Template
MS Access 20077 How to pass text field data from form to table