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
From excel 2003 to 2007 problem
SQL 2005
acOLECreateLink
Access Query "Not equal to" in Query
lost SSIS packages
IBM X3200 with LSI RAID, slow disk performance in Hyper-V virtual machine ?
formula to split data
How to automate cascading option boxes on a web page using Access 2000 VBA
External DNS for OWA with NLB
Outlook 200x Problems Connecting to Exchange Server 2007