My database looks basically like:
auditDocuments:
ID
LoanID
LOID
Timestamp
Filename
auditDocumentPages:
ID
DocumentID
Size
Data
FormID
Timestamp
So I have a Loan, we'll give it loan number DEVNET-12345. Since each document may or may not have all the pages I need, I have to look at all pages for all documents for that loan number. So I need to get all auditDocument with LoanID=DEVNET-12345. But if two documents for this loan have page with FormID of 1234, I only want the the page for FormID=1234 that has the most recent Timestamp.
My query so far:
Code: Select all
SELECT * FROM auditDocumentPages INNER JOIN auditDocument ON auditDocumentPages.DocumentID=auditDocument.ID WHERE auditDocument.LoanID='someloan' ANDThanks!