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
Can I sync Contacts and Calendar with my ITouch
How do I create a Public Folder using Exchange Online through Microsoft Online Services?
No Driver for Ricoh Aficio SP C210SF (Win 7)
SQL Function
Code Behind Value in Hyperlink Field
How to change the location of Listbox using code
Use range of Cells as criteria for Excel Query
error with web site when it was moved from server 2003 to 2008
Access 2000 Runtime
Internet Explorer 8 in Windows 7 does not display page