Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Last 3 records

Status
Not open for further replies.

gi11ies

Programmer
Mar 26, 2002
52
Im wondering how I return the last three records in any table?

Any help would be great

Gillies
 
It depends to the Primary Key field.
Set a query like

Code:
SELECT TOP 3 tblIssue.IssueID
FROM tblIssue
ORDER BY tblIssue.IssueID DESC;

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Tables in a relational database do not have any inherent ordering of records so the term "last three" has meaning only in respect of some some particular ordering that you define for the table. The usual way is something like
Code:
Select TOP 3 fld1, fld2, fld3, ...
From tbl
Order By fld1, fld2;
and you specify the Order By clause to bring the three records that you want to the top of the list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top