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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return top 5 records

Status
Not open for further replies.

ozpeppers

Programmer
Jul 17, 2001
32
0
0
BN
Hello all,

I'm trying to return the last 5 entered records into a table by:

SELECT TOP(5)
tbl_link.id
,tbl_link.title
,tbl_link.urlPath

FROM tbl_link

ORDER BY tbl_link.id DESC;

Access keeps throwing an error...

Does anyone know the correct code?

Thanks in advance
 
First, try getting rid of the parentheses:
Code:
SELECT TOP 5
        tbl_link.id
       ,tbl_link.title
       ,tbl_link.urlPath

FROM tbl_link

ORDER BY tbl_link.id DESC;
Second, you will have to include a date/time field in your order by clause to be able to return the 5 most recent records....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top