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
SQL statement to find and replace character in field...
"The parameter is incorrect" when opening Access database
Problem with DNS
WINXP OUTLOOK EXPRESS LOST INBOX
Access 2000: Changing the Pagesize of a Report at runtime
Iterate through Pivot Items from Cube
Data conversion using MS BizTalk 2009
Is there a broken links reporting tool available for SharePoint?
Entering No Data in a Microsoft Access Date Field
Find & Replace on all views, stored procedures, functions in a given database/server