Page 1 of 1

Simple query question

Posted: Tue Nov 15, 2005 3:24 am
by Shendemiar
How do i select 20 records, those that are added last to the database?

Posted: Tue Nov 15, 2005 4:06 am
by jayshields

Code: Select all

SELECT * FROM table ORDER BY record DESC LIMIT 20
Supposing you've got an auto incrementing record as an ID in your DB or a date for each DB entry, change the field for 'record'. I don't know if it's ASC or DESC without trying it myself, I always get confused.

HTH somehow though :)

Posted: Tue Nov 15, 2005 5:23 am
by foobar
jayshields wrote:

Code: Select all

SELECT * FROM table ORDER BY record DESC LIMIT 20
Supposing you've got an auto incrementing record as an ID in your DB or a date for each DB entry, change the field for 'record'. I don't know if it's ASC or DESC without trying it myself, I always get confused.

HTH somehow though :)
It's ASC. ASC = ascending = increasing; DESC = decending = decreasing. ;)

Posted: Tue Nov 15, 2005 5:29 am
by jayshields
yeah im stupid, but not that stupid :)

i just forget which way it sorts dates sometimes :) like if it was ascending would it show the oldest date last?

Posted: Tue Nov 15, 2005 5:30 am
by timvw
My mother tongue is Dutch (although my French isn't that bad either) and i also had hard times to remeber it.

Here is the trick i used to remember it DESC descending - descendre (coming down in french)