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
error with web site when it was moved from server 2003 to 2008
modifying the default color palette
Error transforming Licenses.licx file after upgrading Active Reports
Serialize/Deserialize Enums to xml in C#
How can I use a combobox field to auto-fill other fields on a form?
Only one parameter passed to function but For Each...Next keeps going after first pass. Can't understand why.
How and where to install SSL Certificate for website?
Can I sync Contacts and Calendar with my ITouch
You were disconnected from the Windows-based computer because of problems during the licensing protocol.
How to use the Switch case in the Report Expression effectively