|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
MS Access SQL Query Help
I'm using Microsoft Access to generate an SQL query for my website URL.
I'm using Microsoft Access which is causing me some trouble. I have an sql query and I wish to return only the most recent record associated with each thread. Instead I get a large number of records for each thread. Here's what my database looks like: Table ThreadTitle ThreadID (Autonumber) Thread (Text) Table Postings ID (Autonumber) IPAddress (text) PostersName (text) DT (text) Location (text) Posting (memo) ThreadInherit (number) Here's my sql query: SELECT ThreadTitle.ThreadID, ThreadTitle.Thread, ID, Postings.IPAddress, Postings.PostersName, Postings.DT, Postings.ThreadInherit FROM ThreadTitle INNER JOIN Postings ON ThreadTitle.ThreadID = Postings.ThreadInherit ORDER BY ThreadTitle.ThreadID; Is there any way to query only the last record for each particular thread? Thanks, Eric Skrzypczak Last edited by ericskrz : April 19th, 2004 at 08:27 AM. |
|
#2
|
||||
|
||||
|
Code:
select ThreadTitle.ThreadID
, ThreadTitle.Thread
, P.ID
, P.IPAddress
, P.PostersName
, P.DT
, P.ThreadInherit
from ThreadTitle
inner
join Postings P
on ThreadTitle.ThreadID = P.ThreadInherit
where P.ID
= ( select max(ID)
from Postings
where ThreadInherit = P.ThreadInherit )
order
by ThreadTitle.ThreadID
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > MS Access SQL Query Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|