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
How can i remove carriage returns from a text file?
Microsoft's Network Security
how to display mapped network drive information in windows explorer
Merging xfdf data into pdf with Internet Explorer Doesnt work
"IFMEMBER" command error in logon scripts. HELP!!!!!!!!!!!!!!
Think I need to convert hyperlink addresses in Access 2007 to absolute paths?
add ALL in combobox rowsource query
Unicode character retrieval from MS-Access
Printer error from Excel Documents
MDB, Library MDA, open a 2nd instance of a Form in MDB from MDA.