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!

SELECT Query Question

Status
Not open for further replies.

Cons

Technical User
May 15, 2002
2
GB
Hi folks.

I have created an .exe in VB6 Enterprise Edition software and I have a little question to ask.

My script currently retrieves information from a database and populates a grid as you would expect. However, I would like my script to return ONLY results say, which have been posted recently - let me explain!

One Table (tbllibrarypublications), Five fields (id, title, publisher, location, description)

I want my SELECT query to ONLY retrieve the last 5 entries in my tbllibrarypublications. Im guessing the best way to do this would be to use the 'id' field, but how would my SELECT Query look?

Any ideas??

 
Probably something like

Code:
SQL = "SELECT id, title, publisher, location, description FROM tbllibrarypublications WHERE id BETWEEN (COUNT(id)-5) AND COUNT(id)"

but thats just my idea
 
Code:
SELECT id, title, publisher, location, description 
  FROM tbllibrarypublications 
  order by id desc 
 limit 5
 
The Limit 5 query worked.

Cheers for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top