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

Select last n records matching a query.

Status
Not open for further replies.

StefIsScared

Programmer
Nov 30, 2004
14
GB
I am trying to select the last n records in a database which conform to criteria selected by a user. I gather that there is no "BOTTOM" equivalent to the "SELECT TOP" command. I've tried "SELECT... ORDER BY... LIMIT X,Y" but MySQL doesn't seem to take a second parameter for the LIMIT statement. Is there any way round this?
 
It does take a second parameter to limit, by why not reverse your 'order by' and take the first n records?
 
I've just tried "SELECT * FROM events ORDER BY event_id DESC LIMIT 10" which I think is what you mean, and for some reason it's throwing up "run-time error '3138': syntax error in ORDER BY clause".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top